Java Interview Question's With Answer:-
Ans:- OOP's is a programming language model organised around a "object" rather than "action" and "data" rather than "logic".
Object : "object" refers to a particular instance of a class where the object can be a combination of variables, functions, and data structures.
Code : in form of procedure often known as method
2)Object Oriented Programming Language's?
Ans:- Languages's that support Abstraction, Encapsulation, Inheritance and Polymorphism. Eg. java, vb, c# etc.
3)What is Abstraction?
Ans:- Abstraction is the process of abstraction in Java is used to hide certain details and only show the essential features of the object.
In other words, it deals with the outside view of an object (interface).
4)What is Encapsulation?
Ans:- Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as as single unit.
In other words, mechanism is used to hide the data, internal Structure and implementation detail of an object.
Interaction with object is only done by public interface.
Example:- Fan ON or OFF by button and Speed is regulate by regulator. User have only detail (interface) of Button and regulator. But user don't know how speed increase and other detail done internally.
5)What is Inheritance?
Ans:- Mechanism in which one object acquires all the properties and behaviour of parent object.
When you inherit from an existing class, you can reuse methods and fields of parent class, and you can add new methods and fields also.
Inheritance represents the IS-A relationship, also known as parent-child relationship.
6)What are the types of Inheritance?
Ans:- Java Supported types of inheritance is as follows:-
Java not Supported types of inheritance is as Follows:-
7)What is polymorphism?
Ans:- Polymorphism is the ability of an object to take on many forms.
The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
Any Java object that can pass more than one IS-A test is considered to be polymorphic.
Note:- Support method overloading and also method Over ridding.
8)What is JDK?
Ans:- Java Development Kit
Java Environment include large number of development tools and hundred of classes and methods.
Development tools are part of system known as JDK.
JDK consist classes and methods as a part of Java Standard Library(JSL) known as Application Programming Interface (API).
9)What is JVM?
Ans:- Java Virtual Machine.
A Java virtual machine (JVM) is an abstract computing machine that enables a computer to run a Java program.
Every system has its own virtual machine which convert (Interpret) Java byte code (i.e .class file) into executable file (i.e .exe file)
10) Steps involve in execution of Java program?
Ans:
11)What is Garbage Collection?
Ans:- Java use to Free the memory.
Clean those object that is no longer refer by any of the program.
Steps involve in Garbage Collection:-
Step 1:- Collect and group all those object which are not refer with any program. Internally call methods viz, runtime.gc() or system.gc().
Step 2:- Run finalize method to free up those object which are collected by java collector.
Note: for more detail about garbage collection visit:-http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
Ans:- The command line arguments are handled using main() function arguments where args refers to the number of arguments passed, and args[] is a pointer array which points to each argument passed to the program.
Basically, an argument supplied to program at time of invoking it for execution.
13) Data types with it's range.
Ans:-
14)Operator's in java with precedence.
Ans:-
15) Control Statement / Branching and Looping?
Ans:-
a. If-Else
Syntax:
if(expression)
statements;
else
statements;
b. while
Syntax:
while(expression)
statements;
c. Do while
Syntax:
do
statements;
while(expression);
d. For statement
Syntax:
for(expression 1; expression 2; expression 3)
statements;
e. Switch
Syntax:
switch(expression)
{
case val-1: block-1
break;
case val-2: block-2
break;
.
......
default: default_block
break;
}
Note:
Break:- to exit or terminate loop or exit from switch.
Continue:- used to bypass the remainder of current pass through loop. It give pass to next pass of loop.
16) How array declared and created?
Ans:- Consists 2 step's:
a. Declare/Creation array vairable:
Syntax: data_type arrayname[];
eg: int x[];
b. Allocation memory using new operator:-
Syntax: arrayname[] = new data_type[size];
eg: x= new int[30];
Note:
above both steps can be done in 1 step as:-
Syntax: array_name[] = new data_type [array_size];
eg: int x[] = new int[30];
17) Array copy method?
Ans:- Syntax:- System.arraycopy(src_array, src_start, target_array, target_start, size);
eg:- System.arraycopy(x,2,z,0,3);
18)What is mean by Constructor?
Ans:-Member function of class i.e used to create an object of that Same Class. Constructor have Same name as Class Itself, No return Type and Invoked using new operator.
19)What is mean by Method?
Ans:-It is Ordinary Member function of Class i.e has its own Name, and have return type(may be void) and invoked using dot( . ) Operator.
20)Difference between Constructor and Method
Ans:-
19) What is mean by Abstract Class?
Ans:- An abstract class is a class that is declared abstract —it may or may not include abstract methods.
Abstract classes cannot be instantiated, but they can be subclassed (i.e inherited).
When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (i.e in abstract class methods are only declare but not implemented, the methods are implemented in the inherited i.e subclass).
20)What is mean by Interface?
Ans:- An interface in Java is similar to a class, but the body of an interface can include only abstract methods and final fields (constants).
A class implements an interface by providing code for each method declared by the interface.
21) Difference between Abstract Class and Interface?
Ans:-
22)Relation between Interface and Abstract Class?
Ans:-
23) State the Significance of Public, Private, Protected and Default modifiers in Java ?
Ans:-
24) What do you mean by static in Java ?
Ans:- Static means One Per Class, Not One for each Object i.e you can use them without creating instance of class.
Static method are implicitly final i.e all instance share the same copy.
Example:- Suppose A class contain method attendance. The method contain an counter for present and absent. So every day when method call it use the previous data and increment present or absent accordingly. Inshort it share the last updated data on every instance.
25)What is mean by Final Class in java?
Ans:- Final class can't be extended i.e not subclassed.
A method can't be Overidden when its class is inherited.
Also You can't change the value of Final vairable (i.e Constant) throught the program execution.









Nice start... Keep updating... Hope for best..
ReplyDelete
ReplyDeleteThis is great advice! Very honest and practical. Love it. Especially the part about the “need to love your job”. Can’t remember that I read anywhere else that it is ok if you have days when you just think work sucks and there is no purpose or meaning. Also: love the color article! Also: love your blog and your work! Keep going HR Interview Questions with Answers,Job Interview Questions and Answers