java
java
java
JAVA
1. What is Java?
Java is a high-level, object-oriented programming language.
2. What are JDK, JRE & JVM? How a Java program compiled or executed? V.
IMP.
JDK (Java Development Kit): Includes tools for Java applica on
development, such as javac, jheap, jconsole etc.
javac tool compile your java file into bytecode (.class file)
JRE (Java Run me Environment): Provides the run me environment for
execu ng Java applica ons, including the JVM.
contains Java class libraries/Java API which assist your java file to
execute.
JVM (Java Virtual Machine): Executes Java bytecode, transla ng it into
na ve machine code. Also do memory management etc.
JIT (Just-In-Time) compiler is a component of the JVM that compiles Java
bytecode into na ve machine code at run me.
Mohd Huzaif
5. How Java is pla orm independent? Why convert java code to bytecode?
Java achieves pla orm independence by compiling source code into
bytecode, which can run on any pla orm with a compa ble JVM.
6. What is main method in Java? What is the role of public, sta c and void in it?
Mohd Huzaif
8. What are variables & data types? What are the types of data ty
Variables are used to store data.
Data types define the type of variable.
Mohd Huzaif
10. What are the differences between primi ve and reference data types?
Mohd Huzaif
13. What is the difference between break and con nue statement? V. IMP.
The break statement is used to terminate the loop completely.
The con nue statement is used to skip the current itera on of the loop
and move on to the next itera on of the loop.
14. What is OOPS? What are the main concepts of OOPS? V. IMP.
OOP stands for Object-Oriented Programming, which means OOPS is a
way to create so ware around objects
OOPs provide a clear structure for the so ware's and web applica ons.
18. When to use String and when to use StringBuilder in real applica ons.
Use String for constant values because Strings are light weight and
therefore improve performance.
Use StringBuilder when concatena ng or modifying strings frequently.
19. What are access specifiers? What are public and private specifiers? V. IMP.
Access specifiers (access modifiers) are keywords used to set the access
level for classes, variables(fields), methods, and constructors.
22. What is the role of this keyword in java? When to use it? V. IMP.
this keyword refers to the current instance of the class.
Use of this keywords: Differen ate between instance variables and
parameters with the same name in se er methods.
23. Why to use same names for class fields and parameter name in Se er
method?
Using the same names for class fields and parameter names in se er
methods can lead to cleaner, more readable code.
25. What is inheritance and when to use inheritance in real applica ons?
Defini on: Inheritance is crea ng a parent-child rela onship between
two classes, where child class will automa cally get the proper es and
methods of the parent.
When to use of inheritance?
Code Reusability: Mul ple Subclasses can reuse fields and methods from
a superclass.
27. Why Java does not support mul ple inheritance of classes? What is
diamond problem?
Mul ple inheritance can lead to the "diamond problem". In diamond
problem, confusion arises if a child class inherits from two parent classes
that have a same name method.
30. What is Method Overloading? How to implement it and when to use it?
Method Overloading occurs when there are mul ple methods with the
same name within the same class but with different parameter lists.
Mohd Huzaif
34. Why to use method overriding? Why don't we have different name
methods?
Method-overriding concept for making our applica on more structured,
readable, and organized.
Mohd Huzaif
36. What are the 5 differences between Overloading and Overriding? V. IMP.
Mohd Huzaif
41. What is the difference between abstrac on and encapsula on? V. IMP
46. What are the differences between an Abstract class & an Interface?
Mohd Huzaif
49. Do abstract class can have Constructors? What is the use of that
constructor?
Mohd Huzaif
51. When to use Interface and when Abstract class in real applica ons?
52. How to achieve abstrac on? Difference between abstrac on and abstract
class?Difference between abstrac on and abstract class?
Abstrac on is a broader concept of hiding complex implementa on
details and showing only the essen al features, whereas abstract class is
a prac cal way to implement Abstrac on.
Mohd Huzaif
63. Can we have mul ple catch blocks and when should we use mul ple catch
blocks?
Mul ple catch blocks are used to: