Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views2 pages

Java 2mark QA

The document provides a list of 20 fundamental questions and answers about Java, covering its features, key components like JVM and JDK, and core concepts such as classes, objects, inheritance, polymorphism, encapsulation, and abstraction. It also explains exception handling, multithreading, method overloading vs. overriding, garbage collection, and the difference between '==' and 'equals()'. This serves as a concise reference for understanding basic Java programming concepts.

Uploaded by

shraddha.kk22
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)
17 views2 pages

Java 2mark QA

The document provides a list of 20 fundamental questions and answers about Java, covering its features, key components like JVM and JDK, and core concepts such as classes, objects, inheritance, polymorphism, encapsulation, and abstraction. It also explains exception handling, multithreading, method overloading vs. overriding, garbage collection, and the difference between '==' and 'equals()'. This serves as a concise reference for understanding basic Java programming concepts.

Uploaded by

shraddha.kk22
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/ 2

Java – 2-Mark Questions and Answers

1. What is Java?
Java is an object-oriented, platform-independent, high-level programming language developed by
Sun Microsystems in 1995.

2. What are the features of Java?


• Object-oriented • Platform independent (Write Once, Run Anywhere) • Simple and secure •
Robust and portable • Multithreaded

3. What is JVM?
Java Virtual Machine (JVM) is a part of JRE that executes Java bytecode and makes Java platform
independent.

4. What is JDK?
Java Development Kit (JDK) is a software package containing JRE, compiler (javac), and
development tools needed to write and run Java programs.

5. What are variables in Java?


A variable is a named memory location that stores data. Example: int age = 20;

6. What are data types in Java?


Java has two categories: • Primitive types (int, float, char, boolean, etc.) • Non-primitive types
(arrays, classes, strings).

7. What is class and object in Java?


• Class: blueprint for objects containing fields and methods. • Object: instance of a class.

8. What is constructor in Java?


A constructor is a special method used to initialize objects. It has the same name as the class and
no return type.

9. What is inheritance?
Inheritance is the process of acquiring properties and methods of one class (superclass) into
another (subclass).

10. What is polymorphism?


Polymorphism means 'many forms'. In Java, it allows methods to perform different tasks based on
object type (method overloading & overriding).

11. What is encapsulation?


Encapsulation is wrapping data (variables) and code (methods) into a single unit called class, with
controlled access using access modifiers.

12. What is abstraction?


Abstraction is the process of hiding implementation details and showing only essential features. It is
achieved using abstract classes and interfaces.

13. What is interface in Java?


An interface is a collection of abstract methods. It is used to achieve full abstraction and multiple
inheritance.

14. What is package in Java?


A package is a collection of related classes and interfaces. Example: java.util, java.io.

15. Difference between final, finally, and finalize?


• final: keyword used for constants, methods, classes. • finally: block used in exception handling. •
finalize: method called before object is garbage collected.

16. What is exception handling?


Exception handling is the mechanism of handling runtime errors using try, catch, finally, throw, and
throws.

17. What is multithreading in Java?


Multithreading is the process of executing multiple threads simultaneously to achieve parallelism.

18. What is difference between method overloading and overriding?


• Overloading: same method name, different parameter list, compile-time polymorphism. •
Overriding: subclass provides new implementation of a superclass method, runtime polymorphism.

19. What is garbage collection?


Garbage collection is the process of automatically reclaiming memory occupied by unused objects
in Java.

20. What is the difference between == and equals()?


• '==' compares reference (memory address). • equals() compares content of objects.

You might also like