In this competitive world, cracking job interviews is not as easy. Hard work is more important. Anxiety is a natural outcome of a job interview. One of the main fear factors is, about the interview questions. Java interview question is trickier as it has some surprising element. It requires some specific knowledge. Here are the most frequently asked JAVA interview questions: Section 1 which helps you to stand strong in interviews.
QUESTION: 1 Why JAVA is called as “Platform Independent?”
Platform independence is defined as the execution of the program which doesn’t dependent on operating systems like Linux, Mac etc. It means after compiling the code once you can run it on any system. Java Training in Chennai teaches both interpreter (JVM) and compiler (javac) based language. Your code is first converted into bytecode. This code can be easily converted into equivalent machine code using JVM which is available in all OS. The bytecode generated by javac is universal and can be converted to machine code on OS and this is the main reason why we say Java is platform independent.
QUESTION: 2 What is called as Final Keyword?
The final keyword in java is used to restrict the usage of class, variable and method. A variable is defined as a constant which cannot be changed. Meanwhile, a method can’t override and class can’t inherit a Final method.
QUESTION: 3 When should we use “super” keyword?
Super keyword is used to refer immediate parent class constructor, immediate parent class method and immediate parent class variable.
QUESTION: 4 Differences between StringBuffer & String
A string is an immutable class, once created cannot be modified. StringBuffer is a mutable class in which you can change its content later. While altering the content in the String object, it creates a new string that doesn’t modify the existing one. This is why StringBuffer is better than String.
QUESTION: 5 Why does Java doesn’t support multiple inheritance?
Java supports multiple inheritance through its interfaces, but not through classes. The reason for not supporting is to avoid complexity and conflict arising due to it and for keeping Java as a Simple Object-Oriented Language. In C++ there is a special case of multiple inheritance with two classes having methods in conflicts. So developers decided to avoid such conflicts and didn’t allow inheritance through classes.
QUESTION: 6 finalize() method
As we do in C++ we don’t need to destroy explicitly in Java. “Garbage Collector” does this for us automatically. Java Course in Chennai checks whether there exist any references to an existing object assumed. In some cases the object can hold non-java resources like database connection or file handle; these resources are released before the object is destroyed. The required tasks are done by overriding this method. After the object is freed, the java runtime calls the finalize() method on it.
Get to know more about the most frequently asked JAVA interview questions from FITA by undergoing JAVA Training.