What is the difference between superclass and subclass?-

?– A super class is a class that is inherited whereas sub class is a class that does the inheriting. In Java, a superclass (or parent class) is a class that is extended by another class, known as the subclass (or child class). The relationship between a superclass and a subclass is part of the … Read more

What is the difference between this() and super()?

this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor. In Java, this() and super() are both used to invoke constructors, but they are used in different contexts and have different purposes: this(): It is used to invoke the current class constructor. … Read more

What is meant by Inheritance and what are its advantages?

Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses. In Java, inheritance is a mechanism that allows one class to inherit the properties and behaviors (fields and methods) of another class. The … Read more

What is difference between overloading and overriding

a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method. b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass. c) In overloading, separate methods share the same name whereas in overriding, … Read more

What is method overloading and method overriding

Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding. In Java, method overloading and method overriding are two important … Read more