Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training
SCJP Online Training » Discussions

Multiple Inheritance not possible

How this line works


class C extends A.B{


public String runNow(){

return "Out";



How does this class work?

Let's intend the program.

class A {

  static class B extends A { }

  class C extends A.B{
    public String runNow(){
      return "Out";
    }
  }
}


Do you see the classes B and [C] are inside the class A ? This is because they are "nested classes". They work just as normal classes, but there are some tricks involved in when you try to access variables and methods within these classes, which takes up a good part in the in the OCPJP objectives. If you haven't heard of nested classes before, I suggest you take a look at the Oracle guide on nested classes for a quick reference:

https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

ExamLab © 2008 - 2024