• +91 9971497814
  • info@interviewmaterial.com

Java Interview Questions Answers

Question 1 : What modifiers may be used with an inner class that is a member of an outer class?

Answer 1 : A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

Question 2 : What classes of exceptions may be caught by a catch clause?

Answer 2 : A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.

Question 3 : How to define an Abstract class?

Answer 3 : A class containing abstract method is called Abstract class. An Abstract class can't be instantiated. Example of Abstract class: abstract class testAbstractClass { protected String myString; public String getMyString() { return myString; } public abstract string anyAbstractFunction(); }

Question 4 : Does a class inherit the constructors of its super class?

Answer 4 : A class does not inherit constructors from any of its superclasses.

Question 5 : How can a GUI component handle its own events?

Answer 5 : A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

Question 6 : What is a Container in a GUI?

Answer 6 : A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.

Question 7 : What is a Java package and how is it used?

Answer 7 : A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

Question 8 : What is a native method?

Answer 8 : A native method is a method that is implemented in a language other than Java.

Question 9 : What is the difference between a static and a non-static inner class?

Answer 9 : A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.

Question 10 : What restrictions are placed on the location of a package statement within a source code file?

Answer 10 : A package statement must appear as the first line in a source code file (excluding blank lines and comments).

Java Contributors

krishan

Share your email for latest updates

Name:
Email:

Our partners