java interview questions

What is Java? Java is the high-level programming language that was developed by James Gosling in the year 1982. It is based on the principles of object-oriented programming and can be used to develop large-scale applications.

"

Scribbled Arrow

Why is Java not a pure object oriented language? Java supports primitive data types - byte, Boolean, char, short, int, float, long, and double and hence it is not a pure object oriented language

"

Scribbled Arrow

What do you mean by data encapsulation?  Encapsulation is an Object-Oriented Programming concept of hiding the data attributes and their behaviours in a single unit.

Scribbled Arrow

Define Copy constructor in java. Copy Constructor is the constructor used when we want to initialize the value to the new object from the old object of the same class.

"

Scribbled Arrow

What is an object? The Object is the real-time entity having some state and behavior. In Java, Object is an instance of the class having the instance variables as the state of the object and the methods as the behavior of the object. The object of a class can be created by using the new keyword.

Scribbled Arrow

What is the constructor? The constructor can be defined as the special type of method that is used to initialize the state of an object. It is invoked when the class is instantiated, and the memory is allocated for the object. Every time, an object is created using the new keyword, the default constructor of the class is called. The name of the constructor must be similar to the class name. The constructor must not have an explicit return type.

Scribbled Arrow

Does constructor return any value? yes, The constructor implicitly returns the current instance of the class (You can't use an explicit return type with the constructor). 

Scribbled Arrow

Is constructor inherited? No, The constructor is not inherited.

Scribbled Arrow