JAVA INTERVIEW
QUESTIONS
Why is Java called Platform Independent
programming Language?
Java is a platform independent programming language
because of the bytecode. Java compiler converts the
source code into the bytecode which can be run on any
platform where the JVM is available. This byte code is
converted into the machine specific code by the Java
Interpreter.
When is super keyword Used?
1. If we have to call the immediate parent class
constructor we use the super keyword.
2. If we have to call immediate parent class
method, we use super keyword.
3. super keyword is used to refer to the parent
class instance variable.
What is the difference between StringBuffer
and String?
A String is an immutable class whereas StringBuffer
is a mutable class. Immutable means unchangeable.
String object can't change its content when it is
once created but a new object is created.
Mutable means content can be modifiable. we can
change the content of StringBuffer object.
How we create a string in Java?
If we are creating string object using the new keyword,
JVM will store it into the Heap Memory.
We can create a string in java by using two ways:
1. By using the new keyword.
2. By using String literal.
If we are creating string object using the String literal,
JVM first checks its availability into the string constant
pool. If it is already present in the pool, JVM creates just
a reference to that string. If not present in the pool JVM
will create a string in the string constant pool.
How we create a thread in Java?
We can create Thread in Java by using two ways:
By Extending a Thread class.
By implementing Runnable interface.
what are the major differences between Java
and C++?
1. Java is a platform independent language whereas C++
is a platform dependent programming language.
2. Java has removed many complex features like
Explicit pointers, Operator overloading, Multiple-
inheritance, Structure, Union etc. Whereas C++
supports all theses features.
www.java2blog.com
Contact Us

Java interview questions

  • 1.
  • 2.
    Why is Javacalled Platform Independent programming Language? Java is a platform independent programming language because of the bytecode. Java compiler converts the source code into the bytecode which can be run on any platform where the JVM is available. This byte code is converted into the machine specific code by the Java Interpreter.
  • 3.
    When is superkeyword Used? 1. If we have to call the immediate parent class constructor we use the super keyword. 2. If we have to call immediate parent class method, we use super keyword. 3. super keyword is used to refer to the parent class instance variable.
  • 4.
    What is thedifference between StringBuffer and String? A String is an immutable class whereas StringBuffer is a mutable class. Immutable means unchangeable. String object can't change its content when it is once created but a new object is created. Mutable means content can be modifiable. we can change the content of StringBuffer object.
  • 5.
    How we createa string in Java? If we are creating string object using the new keyword, JVM will store it into the Heap Memory. We can create a string in java by using two ways: 1. By using the new keyword.
  • 6.
    2. By usingString literal. If we are creating string object using the String literal, JVM first checks its availability into the string constant pool. If it is already present in the pool, JVM creates just a reference to that string. If not present in the pool JVM will create a string in the string constant pool.
  • 7.
    How we createa thread in Java? We can create Thread in Java by using two ways: By Extending a Thread class. By implementing Runnable interface.
  • 8.
    what are themajor differences between Java and C++? 1. Java is a platform independent language whereas C++ is a platform dependent programming language. 2. Java has removed many complex features like Explicit pointers, Operator overloading, Multiple- inheritance, Structure, Union etc. Whereas C++ supports all theses features.
  • 9.