#1 Random Questions for practice on Basic Java Programing
Random Questions for practice on Basic Java Programing
Given below is a
comprehensive list of the most important and commonly asked basic and advanced
Java programming interview questions with detailed answers.
Q #1) What is JAVA?
Answer: Java
is a high-level programming language and is platform-independent.
Java is a collection
of objects. It was developed by Sun Microsystems. There are a lot of
applications, websites, and games that are developed using Java.
Q #2) What are the features of JAVA?
Answer: Features of Java are as follows:
- OOP
concepts
·
Object-oriented
·
Inheritance
·
Encapsulation
·
Polymorphism
·
Abstraction
- Platform
independent: A single program works on
different platforms without any modification.
- High
Performance: JIT (Just In Time
compiler) enables high performance in Java. JIT converts the bytecode into
machine language and then JVM starts the execution.
- Multi-threaded: A flow of execution is known as a Thread. JVM
creates a thread which is called the main thread. The user can create
multiple threads by extending the thread class or by implementing the
Runnable interface.
Q #3) How does Java enable high performance?
Answer: Java
uses Just In Time compiler to enable high performance. It is used to convert
the instructions into bytecodes.
Q #4) Name the Java IDE’s?
Answer: Eclipse
and NetBeans are the IDE’s of JAVA.
Q #5) What do you mean by Constructor?
Answer: Constructor can be explained in detail with enlisted
points:
- When a new object is created in
a program a constructor gets invoked corresponding to the class.
- The constructor is a method
which has the same name as the class name.
- If a user doesn’t create a
constructor implicitly a default constructor will be created.
- The constructor can be
overloaded.
- If the user created a
constructor with a parameter then he should create another constructor
explicitly without a parameter.
Q #6) What is meant by the Local variable and the Instance
variable?
Answer:
Local variables are defined in the method and scope of the variables that
exist inside the method itself.
Instance variable is defined inside the class and outside the method and the
scope of the variables exists throughout the class.
Q #7) What is a Class?
Answer: All
Java codes are defined in a Class. It has variables and methods.
Variables are attributes which define the state of a class.
Methods are
the place where the exact business logic has to be done. It contains a set of
statements (or) instructions to satisfy the particular requirement.
Example:
|
public class Addition{
//Class name declaration int a
= 5; //Variable declaration int b=
5; public void add(){
//Method declaration int c
= a+b; } } |
Q #8) What is an Object?
Answer: An
instance of a class is called an object. The object has state and behavior.
Whenever the JVM reads
the “new()” keyword then it will create an instance of that class.
Example:
|
public class Addition{ public static void main(String[]
args){ Addion
add = new Addition();//Object creation } } |
The above code creates
the object for the Addition class.
Q #9)What is statements in java?
Answer: there are 3 types of statement in java:
- if- else
- switch case
if -else
public class Addition{ //Class name declaration int a = 5; //Variable declaration int b= 5; public void add(){ //Method declaration if(a!=0){//statement is true then it will be executes int c = a+b; }else{ System.out.println("it is negative value"); } }} switch() statement :- -> 1 its a conditional statement having in the block and code -> is execute when the statement is match to given case. -> is false then executes default statement ie,->
|
Q #10)What are the OOPs concepts?
Answer: OOPs concepts include:
- Inheritance
- Encapsulation
- Polymorphism
- Abstraction
- Interface
Comments
Post a Comment