Java Interview Questions

« Java Tutorial Java Programs »

Before going for any interview for the selection on any post related to Java, then you must have to get some idea about interview questions. That is, how interviewers ask questions in interview hall. So to crack Java interview, you must have go through the most important and frequently asked Java interview questions.

This can also helps you to feel better in Java Interview (Java Practical Examination Hall). Here we listed only those Java questions, that can be frequently asked in the Java interview or Java practical examination.

Question 1) What do you understand by procedural programming paradigm ?

The programming approach that focuses on the procedures for the solution of a problem is known as procedural programming paradigm. This approach emphasizes on the 'doing' rather than the 'data'.

Question 2) How is modular programming approach different from procedural programming approach ?

In modular programming, a set of related procedures with the data they manipulate is combined under a until called module. Where there is no grouping of procedures with related data, the procedural programming approach still applies.

Question 3) What is the difference between an object and a class ?

An object is an identifiable entity with some characteristics and behaviour. It represents an entity that can store data and its associated functions.

A class is a group of objects that share common properties and relationships. It represents a group of similar objects. more detail

Question 4) What do you mean by Abstraction and Encapsulation ?

Abstraction is the act of representing essential features without including the background details. And encapsulation is the way of combining both data and the functions that operate on the data under a single unit.

Question 5) How Abstraction and Encapsulation are interrelated ?

Encapsulation is the way of implementing abstraction.

Question 6) What is the difference between base class and derived class ?

A derived class is a class that inherits properties by some other class. And a base class is a class whose properties are inherited by derived class.

Question 7) How base class and derived class are interrelated ?

A derived class has nearly all the properties of base class but the reverse of it is not true.

Question 8) What is polymorphism ?

It is the ability for a message or data to be processed in more than one form. It is a property by which the several different objects respond in a different way (depending upon its class) to the same message. more detail

Question 9) What is inheritance ?

Inheritance is the capability of one class of things to inherit the capabilities or properties from another class.

Question 10) What is modularity ?

The property of decomposing a system into a set of cohesive and loosely coupled modules.

Question 11) How can you say that Java is both a programming language and a platform ?

Like any other programming language, we can use Java to write or create various types of computer applications. The word platform generally used to refer to some combination of hardware and system software. The Java platform is a new software platform designed to deliver and run highly interactive, dynamic and secure applications on networked computer systems.

Question 12) How is ordinary compilation process different from Java compilation ?

In ordinary compilation, the source code is converted to a machine code, which is dependent upon the machine or the platform. This resultant machine code is called native executable code. Contrary to ordinary compilers, the Java compiler does not produce native executable code for a particular machine. Instead it produces a special format called byte code. The Java byte code looks a lot like machine language, but unlike machine language Java byte code is exactly the same on every platform.

Question 13) What do you understand by JVM ?

JVM stands for Java Virtual Machine. The Java Virtual Machine is an abstract machine designed to be implemented on the top of existing processors. It hides the underlying operating system from Java applications. Program written in Java are compiled into Java Byte code, which is then interpreted by a special Java Interpreter for a specific platform. Actually this Java interpreter is known as the Java Virtual Machine (JVM).

Question 14) What is Write Once Run Anywhere characteristic of Java ?

The Java programs need to be written just once, which can be run on different platforms without making changes in the Java program. Only the Java interpreter is changed depending upon the platform. This characteristic is known as Write Once Run Anywhere.

Question 15) What gives Java 'write once and run anywhere' nature ?

The bytecode. Java is compiled in byte code which is the intermediate language between the source code and the machine code. This byte code isn't platform specific and hence can be fed to any platform. This gives Java 'write once and run anywhere' nature.

Question 16) What is an initial class ?

A Java program can contain many classes. But one class in a Java program can contain the main method. This class is called initial class.

Question 17) What is the significance of method main ?

All Java applications begin their execution from main method. If no main method is there in a Java program, then no execution takes place.

Question 18) Name two types of Java programs ?

The two types of Java application are Internet applets and Stand alone applications.

Question 19) How are Internet applets different from stand alone applications of Java ?

Internet applets can't run on their own. They run from within a web browser whereas Java stand alone applications can run independently on any platform.

Question 20) What is bytecode ?

A machine instruction for a Java processor chip called Java Java Virtual Machine (JVM).

Question 21) What is Java API ?

Java Application Programming Interface. Libraries of compiled code that can be used in Java programs.

Question 22) What are the different between keywords and identifiers ?

Keyword is a word carrying special meaning and purpose. And Identifiers are user defined names for different parts of program.

Question 23) What are Literals ?

Literals are data items that never change their value during a program run. more detail

Question 24) What is variable ?

A variable is a named memory location, which holds a data value of a particular data types.

Question 25) What is the difference between implicit type conversion and explicit type conversion ?

Implicit type conversion is performed by Java compiler wherein smaller data types are promoted into higher data types. And explicit type conversion is performed by the programmer using (type) operator, this process is also known as type casting.

Question 26) What is type casting ?

Explicit conversion of an operand to a specific type. more detail

Question 27) What is the difference between while loop and do-while loop ?

The while loop evaluates a test-expression before allowing entry into the loop. And the do-while loop is executed at least once always as it evaluates the test expression at the end of the loop.

Question 28) What does a break statement do ?

A break statement terminates the current loop and proceeds to the first statement that follows that loop.

Question 29) What does a labelled break statement do ?

A labelled break statement terminates the current loop and proceeds to the first statement that follows that loop that is labelled by the identifier that follows the keyword break.

Question 30) What do you understand by infinite loop ?

A loop that never ends.

Question 31) What are the advantages of using functions in programs ?

There are many advantages of using functions in programs, but the major advantages are:

Question 32) What is the difference between Call by Value and Call by Reference ?

In Call by Value, the called function creates its own work copy for the passed parameters and copies the passed values in it. Any changes that take place remain in the work copy and the original data remains intact.

In Call by Reference, the called function receives the reference to the passed parameters and through this reference, it accesses the original data. Any changes that take place are reflected in the original data.

Question 33) What is the significance of constructors in OOP classes ?

One major characteristic of OOP is its close correspondence with the real-world entities. Like real-world entities, OOP objects also are created and scrapped. When an object is created, it must be constructed with some logical initial value automatically without being specified by the programmer. In this job of initializing an object, some legal value is carried out by the constructor of the class, the object belongs to. Therefore, the constructor takes over this very important duty of initialization of an object being create and relieves us from this task.

Question 34) What is this keyword ?

The member functions of every object have access to a sort of magic keyword named this, which points to the object itself. Thus any member function can find out the address of the object of which it is a member. The this keyword represents an object that invokes a member function. It stores the address of the object that is invoking a member function and it (this keyword) is an implicit argument to the member function being invoked.

Question 35) What is the significance of this keyword ?

The this keyword is useful in returning the object (address) of which the function is a member.

Question 36) What is recursion ?

In a program, if a function calls itself (whether directly or indirectly), is known as recursion.

Question 37) What is the difference between iteration and recursion ?

In iteration, the code is executed repeatedly using the same memory space. That is, the memory space allocated once, is used for each pass of the loop. On the other hand, in recursion, since it involves function call at each step, fresh memory is allocated for each recursive call. For this reason, i.e., because a function call overheads, the recursion function runs slower than its iterative counterpart.

Question 38) What is the difference between actual parameters and formal parameters ?

Actual parameters also called as arguments. The variables or values passed to a function. And Formal parameters also called as parameters. The variables that receive the incoming values in a function.

Question 39) What do you understand by and System.out ? and System.out refer to input stream and output stream respectively, managed by System class.

Question 40) What is an Exception ?

Exception in general refers to some contradictory or unusual situation which can be encountered while executing a program.

Question 41) When Exception Handling required ?

The exception handling is ideal for :

Question 42) What is the function of catch block in exception handling ?

A catch block is a group of Java statements that are used to handle a raised exception.

Question 43) What are the advantage of exception handling ?

Advantages of exception handling are :

Question 44) What do you understand by an Array ?

An arrays is a collection of variables of the same type that are referenced by common name.

Question 45)What is file ?

A bunch of bytes stored on some storage device.

Question 46) What is the difference between text files and binary files ?

In text files, data are stored as per a specific character encoding scheme e.g., ASCII text or Unicode text is stored.

In binary files, data are stored in the form of bytes that are in machine readable form.

Question 47) What is stack ?

A stack is a linear structure implemented in LIFO (Last In First Out) manner where insertions and deletions take place only at one end i.e., the stack's top.

Question 48) What do you understand by pushing and popping ?

An insertion in a stack is called pushing and a deleting from a stack is called popping.

Question 49) What do you understand by OVERFLOW and UNDERFLOW ?

When a stack, implemented as an array, is full and no new element can be accommodated, it is called an OVERFLOW.

When a stack is empty and an element is tried to delete from the stack, it is called an UNDERFLOW.

Question 50) What is Queue ?

A queue is a linear structure implemented in FIFO (First In First Out) manner where insertions can occur only at the "rear" end and deletions can occur only at the "front" end.

Question 51) What are Circular Queues ?

Circular Queues are the queues implemented in circle form rather than a straight line.

« Java Tutorial Java Programs »


Quick Links
Signup - Login - Give Online Test