The answer is given at the end
Questions
1. What is Java?
2. What is the JVM?
3. What is the difference between ==
and .equals()
in Java?
4. What is a class in Java?
5.What is an object in Java?
6. What are the access modifiers in Java?
7. What is a constructor?
8. What is the main
method in Java?
public static void main(String[] args) {
// code...
}
9. What is method overloading?
10. What is inheritance in Java?
Answers
1. What is Java?
Java is a high-level, object-oriented programming language developed by Sun Microsystems (now owned by Oracle).
It is platform-independent thanks to the Java Virtual Machine (JVM).
2. What is the JVM?
JVM stands for Java Virtual Machine. It runs Java bytecode and allows Java programs to be platform-independent ("write once, run anywhere").
3. What is the difference between ==
and .equals()
in Java?
-
==
compares object references (memory address). -
.equals()
compares the actual values inside objects (if overridden properly).
4. What is a class in Java?
A class is a blueprint for creating objects. It defines properties (fields) and behaviors (methods).
5.What is an object in Java?
An object is an instance of a class. It contains the state and behavior defined by its class.
6. What are the access modifiers in Java?
-
public
: accessible from anywhere -
private
: accessible only within the class -
protected
: accessible within the package and subclasses - default (no keyword): accessible within the same package
7. What is a constructor?
A constructor is a special method used to initialize new objects. It has the same name as the class and no return type.
8. What is the main
method in Java?
main
method is the entry point of any standalone Java application.
9. What is method overloading?
Method overloading means defining multiple methods in the same class with the same name but different parameters.
10. What is inheritance in Java?
Inheritance allows one class to acquire the properties and methods of another class using the extends
keyword.
Top comments (0)