You are on page 1of 4

Java and J2EE Technologies Real Time Interview Material

Prepared By RamaRao Chowdary Gangavarapu


JVM Concept

Why Java is called Object Oriented programming Language? – Asked in Mind Tree and Polaris Company Interview
Everything is represented as an object is known as truly object-oriented programming language.
Java is not pure object oriented due to primitives. But its most of the features of oops, that’s why it is called Object oriented.
If we use Wrapper classes, instead of primitive then it will become pure object oriented language.
· Object
· Class
· Inheritance
· Polymorphism
· Abstraction
· Encapsulation
What is class in Java? - Asked in Mind Tree Company Interview
A class is nothing but a blue print of an object.
What is object in java? – Asked in Mind Tree Company Interview
An object is a software bundle of variables and related methods. An object is an instance of a class.
Java Keywords?
Abstract Assert Boolean Break

Byte Case catch Char

Class Const continue Default

Do Double else Enum

Extends Final finally Float

For Goto if Implements

Import Instanceof int Interface

Long Native new Package

Private Protected public Return

Short Static strictfp Super

Switch Synchronized this Throw

Throws Transient try Void

Volatile While

How JVM will work and what is the class Loader in java? – Asked in TEK Systems Company Interview
JVM contains both compiler and interpreter but other languages having only compiler or interpreter.
1) Class loader: Java Class Loader loads a java class files into java virtual machine. The default class loader only knows how
to load the class files into local file system. Class loader reads this byte code and creates the instance of java.lang.Class.
Class not found exception.
No Class def found error.
Bootstrap Class Loader: Bootstrap class loader loads java's core classes like java.lang, java.util etc. These are classes that are
part of java runtime environment.
Extension Class Loader: JAVA_HOME/jre/lib/ext contains jar packages that are extensions of standard core java classes.
Extensions class loader loads classes from this ext folder. Using the system environment propery java.ext.dirs you can add
‘ext' folders and jar files to be loaded using extensions class loader.

1 Author By RamaRao Chowdary Gangavarapu …… Real Time Java and J2EE Technologies Interview Material
System Class Loader: Java classes that are available in the java class path are loaded using System class loader.

2) Byte code verifier: It will check that particular .class file is existing or not.
3) JIT (Just in Time) compiler and interpreter: java is a platform independent language which means it can be operated in
any operating system. when you execute a program in C && C++ a .exe file is obtained which contains the source code and
operating system details where as when you execute a program in java a .class file is created which contains the byte
code(source code) only. It is the JVM which links this byte code with the operating system details.
Java classes and instances objects where it will store and which memory? – Asked in Capgemini Company Interview
Stack and heap are the memories allocated by the OS to the JVM that runs in the system. Stack is a memory place where
the methods and the local variables are stored. (Variable references either primitive or object references are also stored in
the stack). Heap is a memory place where the objects and its instance variable are stored.
 Class objects, including method code and static fields: heap.
 Objects, including instance fields: heap.
 Local variables and calls to methods: stack
What is the difference between ClassNotFoundException and NoCLassDefFoundError? - Asked In IBM and Ness
Technologies Companies Interviews
ClassNotFoundException means that the class loader cannot load class A.
ClassDefNotFoundError means that the class loader can load class A, but cannot instantiate it because it cannot load the
other classes that class A depend on.
What is the difference between JDK and JRE and JVM?
JDK is the java development kit contains the executable files.
JRE is the java run time environment contains all the runtime jar files.
JVM is the java virtual machine which is used to convert the byte code to user understandable code.
What is the use of Garbage collection in java? How JVM will remove unwanted objects?
 Assign reference variable to null then GC will remove automatically.
 When a java object is unreachable to a program at that time the garbage collector reclaims the memory of an
object. It is controlled by the JVM, The JVM runs periodically by using "mark" and "sweep" algorithms.
 Object count reference of zero then it is ready for GC.
 System.gc() method may be used to call it explicitly.
Syntax: Runtime r = Runtime.getRuntime();
r.gc();
JVM is interpreter or compiler?
JVM is an Interpreter first it will compile after that it interprets the Java Byte Code which it is feed and then it
executes it line by line.
 Static member classes
 Member classes
 Local classes
 Anonymous classes
What is the main difference between jdk1.4 and jdk1.5?
Jdk 1.5 has various features which were not in jdk 1.4. These new features are below-
1) Annotation
2) Auto Boxing
3) Enum support
4) ForEach
5) Generic implementation of Class Method Wildcards Bounded Type.
6) Variable Argument support
What is the difference between jdk 1.5 and 1.6?

2 Author By RamaRao Chowdary Gangavarapu …… Real Time Java and J2EE Technologies Interview Material
The overall aim of JDK 1.6 was to provide improved service over JDK 1.5.
JDK 1.5 also called JDK 5.0 and JDK 1.6 is also referred to as JDK 6.0.
Applications run faster on JDK 1.6 as opposed to JDK 1.5.
JDK 1.6 is the first Java application to support Vista.
JDK 1.6 comes with JavaScript integration in platform.
JDK 1.6 is lightweight and light on system resources.
JDK 1.6 has an appealing and simplified GUI.
JDK 1.6 allows support of NetBeans IDE 5.5.
JDK 1.6 also comes with improved security features.
What is the use of auto boxing in java?
Java 5 supports automatic conversion of primitive types into wrapper classes in assignments and method and constructor
invocations. This conversion is known as auto boxing.

Primitive data type Wrapper class

Byte Byte

Short Short

Int Integer

Long Long

Float Float

Double Double

Char Character

Boolean Boolean

Auto Unboxing: Java 5 also supports automatic unboxing, where wrapper classes are automatically converted int
o their primitive types if needed for assignments or method or constructor invocations.

public class WrappingUnwrapping{


public static void main(String args[]) { // data types
byte grade = 2;
int marks = 50;
float price = 8.6f; // observe a suffix of <strong>f</strong> for float
double rate = 50.5;
// data types to objects
Byte g1 = new Byte(grade); // wrapping
Integer m1 = new Integer(marks);
Float f1 = new Float(price);
Double r1 = new Double(rate);
// let us print the values from objects
System.out.println("Values of Wrapper objects (printing as objects)");
System.out.println("Byte object g1: " + g1);
System.out.println("Integer object m1: " + m1);
System.out.println("Float object f1: " + f1);

3 Author By RamaRao Chowdary Gangavarapu …… Real Time Java and J2EE Technologies Interview Material
System.out.println("Double object r1: " + r1);

4 Author By RamaRao Chowdary Gangavarapu …… Real Time Java and J2EE Technologies Interview Material

You might also like