What is interface and its use?-

Interface is similar to a class which may contain method’s signature only but not bodies and it is a formal set of method and constant declarations that must be defined by the class that implements it. Interfaces are useful for: a)Declaring methods that one or more classes are expected to implement b)Capturing similarities between unrelated … Read more

What is a reflection package?-

java. lang. reflect package has the ability to analyze itself in runtime. In Java, the reflection package refers to the java.lang.reflect package. Reflection is a feature in Java that allows you to inspect or manipulate the runtime behavior of applications. It provides a way to examine or modify the behavior of classes, interfaces, fields, methods, … Read more

What is a package?-

?– A package is a collection of classes and interfaces that provides a high-level layer of access protection and name space management. In Java, a package is a way to organize related classes and interfaces into a single unit. It helps in avoiding naming conflicts and provides a modular structure to the code. A package … Read more

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