Java Programming Interview Questions and Answers - 2

Question: 6

What is the use of interface?

An interface is a collection of public abstract methods and read only i.e. public, static and final variables. The concepts off interfaces in Java make Multiple Inheritance a reality. Two or more non related classes can implement the same interface,

A class can implement multiple interfaces.

Question: 7

What is public?

If we declare it as a public, classes, subclasses within the package and outside the package, can access it.

Question: 8

What is private?

It can’t be accessed anywhere other than the same class.

Question: 9

What restrictions are placed on method overriding?

Overridden methods must have the same name, argument list and return type.

The overriding method may not limit the access of the method it overrides.

The overriding method may not throw exceptions that may not be thrown by the overridden method.

Question: 10

What is final?

The final prevents its contents from being modified.

Related Questions