1.What is Java?
Java is a platform-independent high-level programming language. It is
platform-independent because its byte codes can run on any system
regardless of its operating system.
2.What are the features of Java?
Object-oriented programming (OOP) concepts
Platform independent
High performance
Multi-threaded
3.What are the OOP concepts?
Inheritance
Encapsulation
Polymorphism
Abstraction
Interface
4. What types of inheritance does Java support?
Single inheritance
Multilevel inheritance
Hierarchical inheritance
Hybrid inheritance
5. What is polymorphism?
Polymorphism is one interface with many implementations. It is used to
enable more than one form for entities, such as variables, functions, or
objects.
6. What are the types of polymorphism, and how do they differ?
Compile-time polymorphism is method overloading.
Run-time polymorphism uses inheritance and interface.
7. What does an interface in Java refer to?
An interface as it relates to Java is a blueprint of a class or a collection
of abstract methods and static constants.
Each method is public and abstract, but it does not contain any
constructor.
8. What are constructors in Java?
In Java, a constructor refers to a block of code used to initialize an object.
Constructors must have the same name as that of the class.
Constructors have no return type.
Creating an object will call a constructor automatically.
9. Name and explain the types of constructors in Java.
Default Constructor :
o Main purpose is to initialize the instance variables with the
default values
o Widely used for object creation
Parameterized Constructor:
o Capable of initializing the instance variables with the provided
values.
o These constructors take the arguments.
10. What is JDK?
JDK stands for Java development kit.
It can compile, document, and package Java programs.
It contains both JRE and development tools.
11. What is JVM?
JVM stands for Java virtual machine.
It is an abstract machine that provides a run-time environment that
allows programmers to execute Java bytecode.
12. What is JRE?
JRE stands for Java runtime environment.
JRE refers to a runtime environment that allows programmers to
execute Java bytecode.
13. In Java, what is a static variable?
A static variable is associated with a class and not objects of that class.
14. What is a JIT compiler?
A JIT compiler runs after the program is executed and compiles the code into
a faster form, hosting the CPU’s native instructing set.
15. How does a JIT compiler differ from a standard compiler?
JIT can access dynamic runtime information, and a standard compiler does
not. Therefore, JIT can better optimize frequently used inlining functions.
16. What is an inner class?
An inner class is a class that is nested within another class. An Inner class
has access rights for the class that is nesting it, and it can access all
variables and methods defined in the outer class.
17. What is a subclass?
A subclass is a class that inherits from another class called the superclass.
Subclass can access all public and protected methods and fields of its
superclass.
18. What is a package in Java?
In Java, packages are the collection of related classes and interfaces which
bundle together.
19. What does the term constructor overloading mean?
Constructor overloading indicates passing different numbers and types of
variables as arguments, all of which are private variables of the class.
20. How are non-primitive variables used in Java?
Non-primitive variables always refer to objects in Java.
21. What is a class in Java?
All Java codes are defined in a class. It has variables and methods.
22. What is a variable within Java?
Variables are attributes that define the state of a class.
23. How do you use a method in Java?
Methods are the place where the exact business logic has to be done.
Methods contain a set of statements or instructions that satisfy specified
requirements.
24. What is a Java object?
An object is an instance of a class. The object has a state and behavior.
25. How do you declare an infinite loop?
An infinite loop runs without any condition and runs infinitely. You can
break an infinite loop by defining any breaking logic in the body of the
statement blocks.
For (;;)
{
// Statements to execute
// Add any loop breaking logic
}