0% found this document useful (0 votes)
3 views

Java_2_and_5_Markers_Formatted

The document outlines important Java concepts, including its features such as platform independence and object-oriented nature, multithreading methods, access modifiers, and the role of the main() method. It also discusses interfaces, inheritance types, differences between Java and C++, and Java's architecture. Additionally, it highlights the advantages and disadvantages of multithreading, inter-thread communication, and Java's safety compared to C++.

Uploaded by

Sidhant Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java_2_and_5_Markers_Formatted

The document outlines important Java concepts, including its features such as platform independence and object-oriented nature, multithreading methods, access modifiers, and the role of the main() method. It also discusses interfaces, inheritance types, differences between Java and C++, and Java's architecture. Additionally, it highlights the advantages and disadvantages of multithreading, inter-thread communication, and Java's safety compared to C++.

Uploaded by

Sidhant Mehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Java Important Questions and Answers

1. Features of Java

- Platform Independent

- Object-Oriented

- Simple and Easy to Learn

- Secure and Robust


Java Important Questions and Answers

2. How is Multithreading achieved in Java?

- By extending the Thread class or implementing Runnable interface.

Advantages:

- Better CPU utilization, Faster execution

Disadvantages:

- Difficult debugging, Risk of synchronization issues


Java Important Questions and Answers

3. Different Access Modifiers in Java

- Private: Accessible only within class.

- Default: Accessible within package.

- Protected: Accessible within package and subclasses.

- Public: Accessible from anywhere.


Java Important Questions and Answers

4. Use of throw and throws keyword

- throw: Used to explicitly throw an exception.

- throws: Declares exceptions a method can throw.


Java Important Questions and Answers

5. Why main() is declared as Public Static void main(String[] args)

- public: JVM accesses main from anywhere.

- static: No object needed.

- void: No return value.

- String[] args: Accepts command-line arguments.


Java Important Questions and Answers

6. What is Interface? Benefits?

- Interface: Blueprint of class with abstract methods.

Benefits: Achieves abstraction, multiple inheritance, loose coupling.


Java Important Questions and Answers

7. What is Inheritance? Types?

- Inheritance: Child class inherits properties of parent class.

Types: Single, Multilevel, Hierarchical inheritance.


Java Important Questions and Answers

8. Why Java is safe compared to C++?

- No pointers, strong memory management (Garbage collection), strict type checking.


Java Important Questions and Answers

9. Key Differences between Java and C++

Feature Java C++

Memory Management Automatic (Garbage Collection) Manual (new, delete)

Pointers No pointers Pointers supported

Type Checking Strong Weak


Java Important Questions and Answers

10. Role of Priorities in Multithreading

- Higher priority threads generally executed earlier.

Limitation:

- Actual execution order depends on OS scheduler.


Java Important Questions and Answers

11. What is Inter-Thread Communication?

- Mechanism for threads to coordinate.

- Uses wait(), notify(), notifyAll() methods from Object class.


Java Important Questions and Answers

12. What is Java Architecture?

- Layers:

- Application Layer (User Code)

- JVM (Runs bytecode)

- JRE (Provides libraries and JVM)

- JDK (Development kit including JRE and compiler)

- JVM ensures platform independence by interpreting bytecode.

You might also like