C | C++ | Java Interview Questions and Answers - 1

Question: 1

What is the difference between a static and non static inner class?

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: 2

What is serializable interface?

In Java.io package there is an interface called java.io.Serializable, which is a syntactic way of serializing objects.

This interface does not define any method. The purpose of serialization is persistence, communication over sockets or RMI.

In Object serialization an object can be converted into byte stream and vice versa.

Question: 3

How are memory leaks possible in java?

If any object variable is still pointing to some object which is no use, then JVM will not garbage collect that object and object will remain in memory creating memory leak

Question: 4

What are the four corners stone’s of OOP?

  • Abstraction
  • Encapsulation
  • Polymorphism and
  • Inheritance

Question: 5

What is the difference between import and static import?

The import allows the java programmer to access classes of a package without package qualification whereas the static import feature allows to access the static members of a class without the class qualification.

The import provides accessibility to class and interface whereas static import provides accessibility to static members of the class.

Related Questions