JAVA Interview Questions Download PDF

1 . Why Java is called as platform independent?

Java is called platform independent because of its byte codes which can run on any system irrespective of its underlying operating system. Any java code internally converted in to its byte code.


2 . Is Java code 100% object orineted?

No it is not 100% object oriented language as it makes use of eight primitive data types like boolean, byte, char, int, float, double, long, short which are not objects


3 . What is the difference between equals() method and == operator in Java?

equals() method is defined in Object class in Java and used for checking equality of two objects. “==” or equality operator in Java is a binary operator provided by Java programming language and used to compare primitives and objects.


4 . What difference between heap and stack memory?

Stack memory only contains local primitive and reference variables to objects in heap space.Stack memory is used only by one thread of execution. Whenever an object is created, it’s always stored in the Heap space in heap memory.Heap memory is used by all the parts of the application


5 . Why the concept of pointers are not used in Java?

Because they are unsafe and increases the complexity of the program. As, Java is known for its simplicity of code, adding the concept of pointers will be contradicting. Moreover, since JVM is responsible for implicit memory allocation, thus in order to avoid direct access to memory by the user, pointers are not introduced in Java.


6 . Why Strings are immutable in Java?

String objects are immutable as String objects are generally cached in the String pool. Since String literals are usually shared between multiple clients, action from one client might affect the rest. It gives security, caching, synchronization, and performance of the application.


7 . What are the advantages of packages in Java?

Packages help in avoiding name clashes They provide easier access control on the code Packages can also contain hidden classes which are not visible to the outer classes and only used within the package Creates a proper hierarchical structure which makes it easier to locate the related classes


8 .  What is multiple inheritance? Is it supported by Java?

If a child class inherits the property from multiple classes is known as multiple inheritance. Java does not allow to extend multiple classes.The problem with multiple inheritance is that if multiple parent classes have the same method name, then at runtime it becomes difficult for the compiler to decide which method to execute from the child class. This problem is resolved in interface.


9 . Is it possible to restrict inheritance ?

Yes, it is. You can restrict Inheritance by: a. Using the final keyword. b. Making the method final. c. Using private constructor. d. Using (//) Javadoc comment.


10 . what is use of this keyword?

In a constructor if I have declared local variable as well as instance variable with same name then this keyword is been used.


Post Question Details

Ques. lkm0ti

Posted On: 4/29/2023 7:34:25 AM


Ques. y4ox23

Posted On: 9/21/2022 7:04:06 PM


Ques. test1

Posted On: 5/2/2020 9:03:54 PM


Ques. tfgukhukhkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkksettttttttttttttttttdt ujgyuihk ihjok;l

Posted On: 3/4/2020 11:20:12 PM