Java Interview Questions together with Answers Part 1
1) What is Java?
• Java is an Object oriented Programming language, In Java every affair is object, coffee tin last easily extended since it is based on Object model.
• Java Programming Language was developed at Lord's Day Microsystems inwards 1991 (The rootage publicly available version of Java (Java 1.0) released inwards 1995, Now it is subsidiary of Oracle corporation.
• Java is a Platform independent language, it tin last compiled together with Interpreted.
• Java is simple, slow to larn together with implement.
• Java is Securable, using Java nosotros tin educate virus costless together with tamper costless systems.
2) What is the role of Java?
• To educate Desktop Applications (ex: Acrobat Reader)
• To educate Web Applications
• To educate Enterprise Applications (Ex: Banking, Insurance Applications etc...)
• To educate Mobile Applications
• To educate Embedded Systems.
• To educate Smart Cards
• To educate Games software etc...
3) What are the of import Java Syntax rules?
• Java is a illustration sensitive language.
• First missive of the alphabet of Class refer should last inwards Upper case.
• Method names should start alongside lower illustration letter.
• Java plan file refer should just agree alongside shape name.
• Java plan execution starts from top dog method, which is mandatory inwards every Java program.
• Every statement/step should terminate alongside semi colon symbol.
• Code blocks enclosed alongside {}.
4) How to setup Java environment?
> Download Java Software (JDK) together with Install.
> Set Environment Variable path (Path variable)
> Download Eclipse IDE together with extract
Launch Eclipse IDE, Create Java project, Create Java Package nether Java project, Create Java Class nether Java packet together with write Java Code & Run/Execute.
5) Explain Java Program Structure?
i) Documentation Section
ii) Package annunciation statement
Ex: packet abcd;
iii) Import Statement/s
We import Built inwards together with User defined libraries using import keyword.
Ex:
import java.io.Console;
import java.lang.*;
java - project
io - Package
Console - Class
iv) Class annunciation
Ex:
public shape Sample {
}
public - Access Modifier
class - Java keyword/reserved give-and-take to declare class
Sample - Class name
--------------------------------------------
v) top dog Method (Java Program execution starts from top dog method)
public static void top dog (String [] args) {
}
public - Access Modifier
static - Non-Access Modifier(use top dog method without invoking whatever Object.)
void - Returns Nothing
main - method name
-------------------
(String [] args)
------------------------------------------
vi) Declarations
We declare Variables together with Constants.
int a;
a =10;
.
.
a=50;
int b =20;
int a, b, c;
int a=10, b=20, c=30, d;
final int y;
y=213; //Incorrect
final int x =100;
x=200; //Incorrect
vii) Normal Statements
d = a + b + c;
System.out.println(c);
System - Class
out - Object
println -Method
--------------------------
viii) Code blocks
Condition blocks
Loop Blocks
Method Blocks etc...
-------------------------------------
6) What are Modifiers inwards Java?
Modifiers are keywords that nosotros add together to those definitions to modify their meaning.
Two types of Modifiers inwards Java
a) Access Modifiers
b) Non Access Modifiers
7) What are Access Modifiers?
We role access modifiers to define access command for classes, methods together with variables.
i) public
public access modifiers is accessible everywhere.
public shape Sample{
}
ii) private
The somebody access modifier is accessible alone inside class.
Ex:
private int a=100;
iii) default
If nosotros don't specify whatever modifier thus it is treated equally default, this tin last accessible alone inside package.
class Sample {
}
iv) protected
The protected modifier is accessible inside package, exterior of the packet just through Inheritance.
protected shape Sample {
}
8) What is Variable?
A named retention place to shop the temporary information inside a program.
Two types of retention inwards Computer environment.
a) Primary retention (RAM)
b) Secondary retention (ROM - HDD, DVD, USB get etc...)
Note: Variables shop inwards Primary memory.
9) What are the naming restrictions to practice Variables?
Variable Naming restrictions
i) Java Variables are illustration sensitive.
ii) Java variable names should start alongside a missive of the alphabet or $ or _
iii) Variable names should non agree alongside Java Keywords/Reserved words
iv) Must last unique inwards the range of declaration.
v) Must non transcend 255 characters.
10) What are types of Variables inwards Java?
Three types of Variables inwards Java:
i) Local Variables
ii) Instance Variables
iii) Class / Static Variables
----------------------------------------------------
Sumber http://www.gcreddy.com/
1) What is Java?
• Java is an Object oriented Programming language, In Java every affair is object, coffee tin last easily extended since it is based on Object model.
• Java Programming Language was developed at Lord's Day Microsystems inwards 1991 (The rootage publicly available version of Java (Java 1.0) released inwards 1995, Now it is subsidiary of Oracle corporation.
• Java is a Platform independent language, it tin last compiled together with Interpreted.
• Java is simple, slow to larn together with implement.
• Java is Securable, using Java nosotros tin educate virus costless together with tamper costless systems.
2) What is the role of Java?
• To educate Desktop Applications (ex: Acrobat Reader)
• To educate Web Applications
• To educate Enterprise Applications (Ex: Banking, Insurance Applications etc...)
• To educate Mobile Applications
• To educate Embedded Systems.
• To educate Smart Cards
• To educate Games software etc...
3) What are the of import Java Syntax rules?
• Java is a illustration sensitive language.
• First missive of the alphabet of Class refer should last inwards Upper case.
• Method names should start alongside lower illustration letter.
• Java plan file refer should just agree alongside shape name.
• Java plan execution starts from top dog method, which is mandatory inwards every Java program.
• Every statement/step should terminate alongside semi colon symbol.
• Code blocks enclosed alongside {}.
4) How to setup Java environment?
> Download Java Software (JDK) together with Install.
> Set Environment Variable path (Path variable)
> Download Eclipse IDE together with extract
Launch Eclipse IDE, Create Java project, Create Java Package nether Java project, Create Java Class nether Java packet together with write Java Code & Run/Execute.
5) Explain Java Program Structure?
i) Documentation Section
ii) Package annunciation statement
Ex: packet abcd;
iii) Import Statement/s
We import Built inwards together with User defined libraries using import keyword.
Ex:
import java.io.Console;
import java.lang.*;
java - project
io - Package
Console - Class
iv) Class annunciation
Ex:
public shape Sample {
}
public - Access Modifier
class - Java keyword/reserved give-and-take to declare class
Sample - Class name
--------------------------------------------
v) top dog Method (Java Program execution starts from top dog method)
public static void top dog (String [] args) {
}
public - Access Modifier
static - Non-Access Modifier(use top dog method without invoking whatever Object.)
void - Returns Nothing
main - method name
-------------------
(String [] args)
------------------------------------------
vi) Declarations
We declare Variables together with Constants.
int a;
a =10;
.
.
a=50;
int b =20;
int a, b, c;
int a=10, b=20, c=30, d;
final int y;
y=213; //Incorrect
final int x =100;
x=200; //Incorrect
vii) Normal Statements
d = a + b + c;
System.out.println(c);
System - Class
out - Object
println -Method
--------------------------
viii) Code blocks
Condition blocks
Loop Blocks
Method Blocks etc...
-------------------------------------
6) What are Modifiers inwards Java?
Modifiers are keywords that nosotros add together to those definitions to modify their meaning.
Two types of Modifiers inwards Java
a) Access Modifiers
b) Non Access Modifiers
7) What are Access Modifiers?
We role access modifiers to define access command for classes, methods together with variables.
i) public
public access modifiers is accessible everywhere.
public shape Sample{
}
ii) private
The somebody access modifier is accessible alone inside class.
Ex:
private int a=100;
iii) default
If nosotros don't specify whatever modifier thus it is treated equally default, this tin last accessible alone inside package.
class Sample {
}
iv) protected
The protected modifier is accessible inside package, exterior of the packet just through Inheritance.
protected shape Sample {
}
8) What is Variable?
A named retention place to shop the temporary information inside a program.
Two types of retention inwards Computer environment.
a) Primary retention (RAM)
b) Secondary retention (ROM - HDD, DVD, USB get etc...)
Note: Variables shop inwards Primary memory.
9) What are the naming restrictions to practice Variables?
Variable Naming restrictions
i) Java Variables are illustration sensitive.
ii) Java variable names should start alongside a missive of the alphabet or $ or _
iii) Variable names should non agree alongside Java Keywords/Reserved words
iv) Must last unique inwards the range of declaration.
v) Must non transcend 255 characters.
10) What are types of Variables inwards Java?
Three types of Variables inwards Java:
i) Local Variables
ii) Instance Variables
iii) Class / Static Variables
----------------------------------------------------