کلمه کلیدی this در جاوا

  • this keyword is another keyword in java language used to point same class object explicitly.
  • this keyword can not used in static block or static method.

Dynamic Polymorphism در جاوا

what is dynamic or run time polymorphism in java?

  • if the method execution is depend on JVM it is named Dynamic Polymorphism.
  • Dynamic poly morphism can be achieved using method overriding.
  • writting more than one method with same name and same signature in super class and sub class is known as method overriding


کلمه کلیدی super در جاوا

  • super is a keyword which is reserved in java language to point to the immediate super class object.
  • super keyword can not be used from static block or static methods.
  • super.super is wrong. we can not use like this

چرا جاوا Multiple Inheritance را Support نمی کند؟

java dose not support multiple inheritance. why?

let if java suppot multple inheritance,suppose i have a class A with method meth(), class B and C are inherited from class A. now method meth() is available to class B and C. using multiple inheritance if inherit B and C class to class D my JVM will go to an ambiguity.
that which method to be inherit. method of class B or method of class C?
because of an ambiguity error, java dose not support multiple inheritance.

نکاتی در مورد Inheritance در جاوا

  • Inheritance is known as getting property of one class to another.
  • in java we can achieve inheritance using the keyword extends.
  • inheritance has 3 types 1-single inheritance 2-multiple inheritance and 3-circular inheritance.
  • no programming language support circular inheritance.
  • Java also doesn't support multiple inheritance.
  • super class object will be created first before the subclass object.
  • super class constructor will get called through the subclass constructor.
  • super class object is available through subclass reference variables.
  • Object class is the super class of all the classes and the object of the Object class will be created first before creation of any other classes.
  • we have reference from subclass to superclass and we don't have reference from super classess to sub classess