What are inner class and anonymous class?-

Inner class : classes defined in other classes, including those defined in methods are called inner classes. An inner class can have any accessibility including private. Anonymous class : Anonymous class is a class defined inside a method without a name and is instantiated and declared in the same place and cannot have explicit constructors. … Read more

What modifiers may be used with top-level class?-

public, abstract and final can be used for top-level class. In Java, a top-level class (i.e., a class that is not a nested or inner class) can have the following modifiers: public: The class can be accessed from any other class. (default, no modifier): If no access modifier is specified, the class is only accessible … Read more

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