Java Programming Interview Questions and Answers - 1

Question: 1

What is difference between object oriented programming language and object based programming language?

Object based programming languages follow the features of OOPs except Inheritance.

Examples of object based programming languages are JavaScript, VBScript etc.

Question: 2

What is static in java?

Static means one per class, not one for each object no matter how many instance of a class might exist. This means that you can use them without creating an instance of a class.

Static methods are implicitly final, because overriding is done based on the type of the object and static methods are attached to a class, not an object.

A static method in a superclass can be shadowed by another static method in a sub class, as long as the original method was not declared final.

However, you can’t override a static method with a non static method. In other words, you can’t change a static method into an instance method of a subclass.

Question: 3

What is abstract class?

A abstract class must be extended/sub classed (to be useful). It serves as a template.

A class that is abstract may not be instantiated, abstract class may contain static data.

Any class with an abstract method is automatically abstract itself and must be declared as such.

A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.

Question: 4

Which keyword is used to prevent overriding?

Final

Question: 5

What is the purpose of the system class?

The purpose of the System class is to provide access to system resources.

Related Questions