0% found this document useful (0 votes)
13 views5 pages

Java OOP Concepts and Features Explained

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)
13 views5 pages

Java OOP Concepts and Features Explained

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

1.

Define Abstraction

• Abstraction is the process of hiding implementation details and showing only the
essential features of an object.

• Achieved using abstract classes and interfaces in Java.

2. Define Class and Object

• Class: A blueprint for creating objects. It defines variables (data) and methods
(behavior).

• Object: An instance of a class that has its own state (data) and behavior (methods).

3. Define JVM

• JVM (Java Virtual Machine) is a software engine that runs Java bytecode.

• It provides platform independence, memory management, and garbage collection.

4. What is Bytecode?

• Bytecode is the intermediate code generated after Java source code is compiled.

• It is machine-independent and executed by the JVM.

5. Why Java is Platform Independent?

• Because Java code is compiled into bytecode, which can run on any system with a
JVM installed.

6. Define Polymorphism

• Polymorphism means "many forms."

• In Java, it allows one entity (method, operator) to behave differently based on


context.

• Two types:
o Compile-time (Overloading)

o Runtime (Overriding)

7. Need of Wrapper Class

• Primitive types (int, char, etc.) are not objects. Wrapper classes (Integer, Character,
etc.) convert primitives into objects.

• Needed for:

o Collections framework (which works with objects only)

o Autoboxing & Unboxing

8. Define Constructor

• A constructor is a special method in a class used to initialize objects.

• It has the same name as the class and no return type.

9. Why Java is Not Purely Object-Oriented?

• Java supports primitive data types (int, char, etc.) which are not objects.

• Hence, not 100% object-oriented.

10. Rules of Constructor

• Must have the same name as the class.

• No return type (not even void).

• Can be overloaded but not inherited.

11. Advantages of OOPs

• Reusability (code reuse through inheritance).

• Modularity (organized code).


• Extensibility (easy to add features).

• Security (encapsulation hides data).

Disadvantages:

• More complex design.

• Slower execution compared to procedural programming in some cases.

• Requires more memory.

12. What are Command Line Arguments?

• //comments---single comments

• /*comments*/---multiple comments

13. Four Features of OOPs

1. Encapsulation

2. Inheritance

3. Polymorphism

4. Abstraction

14. Applications of OOPs

• Real-time systems (banking, e-commerce).

• GUI applications.

• Simulation and gaming.

• Web and mobile applications.

15. Define Array and Create with new Operator

• Array: A collection of elements of the same type stored in contiguous memory


locations.
• Example:

• int arr[] = new int[5];

16. Some Array Functions (Methods in Java)

• length → gives size of array.

• [Link](arr) → sorts the array.

• [Link](arr, key) → searches element.

• [Link](arr1, arr2) → compares arrays.

17. Define Inheritance

• Inheritance is the process by which one class (child/subclass) acquires properties


and behaviors of another class (parent/superclass).

18. Object-Oriented Features

• Abstraction

• Encapsulation

• Polymorphism

• Inheritance

19. Compare Overloading & Overriding

• Overloading:

o Compile-time polymorphism.

o Same method name but different parameters.

• Overriding:

o Runtime polymorphism.

o Child class provides its own implementation of a method defined in the


parent class.
20. Types of Inheritance in Java

• Single Inheritance

• Multilevel Inheritance

• Hierarchical Inheritance
(Note: Java does not support Multiple Inheritance directly, but supports it via
Interfaces.)

21. Compare Constructor & Other Methods

• Constructor:

o Same name as class.

o No return type.

o Called automatically at object creation.

• Method:

o Any name (except class name).

o Must have a return type.

o Called explicitly.

22. How Encapsulation is Achieved in Java?

• By declaring variables private and providing public getters & setters to access
them.

23. Why Java Does Not Support Multiple Inheritance?

• To avoid ambiguity problem (Diamond Problem).

• Example: If two parent classes have the same method, child class won’t know
which one to inherit.

• Java solves this using interfaces instead.

You might also like