Home APPS Development Gaming Mobile TECHNOLOGY Software Hordware OTHERS Multiple Choice Question (MCQ) Login

Java Basic Interview Question And Answer

Categories: TECHNOLOGY

Ques. What is Java? 

Ans. Java is a 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. 


Ques. Why is Java a platform independent language?

Ans. Java language was developed so that it does not depend on any hardware or software because the compiler compiles the code and then converts it to platform-independent byte code which can be run on multiple systems.


Ques. Why is Java not a pure object oriented language?

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


Ques. Difference between Heap and Stack Memory in java. And how java utilizes this.

Ans. Stack memory is the portion of memory that was assigned to every individual program. And it was fixed. On the other hand, Heap memory is the portion that was not allocated to the java program but it will be available for use by the java program when it is required, mostly during the runtime of the program.


Ques. Can java be said to be the complete object-oriented programming language?

Ans. It is not wrong if we claim that Java is the complete object-oriented programming language because everything in Java is under the classes and we can access them by creating the objects.

But we can even say that Java is not a completely object-oriented programming language because it has the support of primitive data types like int, float, char, boolean, double, etc.


Ques.  How is Java different from C++?

Ans. C++ is only a  compiled language, whereas Java is compiled as well as an interpreted language.

Java programs are machine-independent whereas a c++ program can run only in the machine in which it is compiled. 

C++ allows users to use pointers in the program. Whereas java doesn’t allow it. Java internally uses pointers. 

C++ supports the concept of Multiple inheritances whereas Java doesn't support this. And it is due to avoiding the complexity of name ambiguity that causes the diamond problem.


Ques. Pointers are used in C/ C++. Why does Java not make use of pointers?

Ans. Pointers are quite complicated and unsafe to use by beginner programmers. Java focuses on code simplicity, and the usage of pointers can make it challenging. Pointer utilization can also cause potential errors. Moreover, security is also compromised if pointers are used because the users can directly access memory with the help of pointers.


Ques. What do you understand by an instance variable and a local variable?

Ans. Instance variables are those variables that are accessible by all the methods in the class. They are declared outside the methods and inside the class. These variables describe the properties of an object and remain bound to it at any cost.

Local variables are those variables present within a block, function, or constructor and can be accessed only inside them. The utilization of the variable is restricted to the block scope. Whenever a local variable is declared inside a method, the other class methods don’t have any knowledge about the local variable.


Ques. What do you mean by data encapsulation?

Ans. Data Encapsulation is an Object-Oriented Programming concept of hiding the data attributes and their behaviours in a single unit.

It helps developers to follow modularity while developing software by ensuring that each object is independent of other objects by having its own methods, attributes, and functionalities.

It is used for the security of the private properties of an object and hence serves the purpose of data hiding.

Java Basic Interview Question And Answer