OOPs Java Specific Questions

Class

  • Class can only be public, abstract or final
  • Default is the default modifier of class
  • The public type Class must be defined in its own file
  • abstract class objects cannot be directly created
  • final class cannot be extended

Method

  • static method can be called via object or class name
  • Parent Child
    • static method can be declared in parent and child class but the method which is called depends on the reference class and not the instance class
    • Animal a = new Dog(); a.methodCall() //Runtime polymorphism
      • In the above scenarion, methodCall() is expected to be executed of Dog class 1st if and only if the method is overriden else Animal method is called.
      • If the method does not exist in the parent class then compile time error will be displayed

To do

Leave a Comment