Java Fundamentals






  • What is JAVA?
Java is a free open source, object oriented programming language. It is platform independent,  supports multithreading and enables high performance.

  • What is JDK?
JDK stands for Java Development Kit. JDK is required to compile and package java programs. It consists of JRE.

  • What is JRE?
JRE stands for Java Runtime Environment. It provides required libraries and JVM to run java programs.

  • What is JVM?
JVM stands for Java Virtual Machine. It is used to execute java programs.

  • What is JIT compiler?
JIT stands for Just In Time. JIT compiler is used to compile byte code into executable code.

  • What are the different primitive data types in Java ?
Following are the primitive data types -
    • char
    • byte
    • short
    • int
    • float
    • double
    • long
    • boolean

  • What are wrapper classes?
For every primitive data type in java we have a corresponding class in java to convert it into an object, these classes are known as wrapper classes.
Following are the wrapper classes - 
    • Character 
    • Byte
    • Short
    • Integer
    • Float
    • Double
    • Long
    • Boolean

  • What is autoboxing and unboxing?
Autoboxing is a way of converting primitive data types to objects and Unboxing is a way to convert objects into primitive data types.

  • What are nested classes?
A class declared within a class is called nested class.

  • What are the different types of nested class?
    • Static Nested Class - It is a nested class declared with static keyword and can be instantiated without creating the object of outer class.
    • Non Static Nested Class - It is a nested class declared without static keyword and is also known as Inner Class.
  • What is a constructor?
A constructor has the name as that of the class, it is a method without any return type, used for creating the object of a class.

  • What are the types of constructors?
Constructors are of two types -
    • Default - Constructor without any parameters.
    • Parameterised - Constructor with parameters.

  • What is static keyword?
Static variables and methods are created to be used by multiple objects. They can be called without creating the object of a class.
Static methods cannot be overridden.
Static block is used to execute a piece of code when the application starts.

  • What is final keyword?
    • Class - If a class is declared as final, then it cannot be extended. Inheritance cannot be achieved if a class is declared as final.
    • Method - If a method is declared as final, it cannot be overridden. Polymorphism cannot be achieved if a method is declared as final.
    • Variable - If a variable is declared as final, its value cannot be changed. It becomes a Constant.

  • What is this() keyword?
this() is used to call one constructor from another within the same class.

  • What is super keyword?
super() is used by sub class to access the variables and methods of super class.

  • What is Serialization?
Serialization is a way to save the state of the object when passing it over a network stream by converting it into bytes.

  • What is transient?
If we do not want a variable to be serialized, we declare it as transient.