Oops Flashcards
Encapsulation
Binding together the data and the functions that manipulates them.
Abstraction
Displaying only essential information and hiding the details
*Abstraction using classes
*Abstraction using Header Files (Math.h)
Polymorphism
Allows the user to invoke the derived class method through base class reference during runtime. Uses overloading and overriding methods
What is Java?
Java is a high-level object-oriented programming language known for its robustness, security, simplicity, and high performance.
Features include simplicity, object orientation, portability, platform independence, security, robustness, architecture neutrality, high performance, multithreading, and dynamic loading of classes.
What does JRE stand for?
Java Runtime Environment
It is part of the JDK and contains components to create and run Java programs.
What is the purpose of JDK?
Java Development Kit is used to develop Java applications and includes tools like compiler and debugger.
It also includes the JRE and JVM.
What is JVM?
Java Virtual Machine, which executes Java programs and is part of the JRE.
It acts as the space where Java programs run.
Define an object in Java.
An instance member of a Java class with its own identity, behavior, and state.
What is a class in Java?
A user-defined blueprint or prototype from which objects are created, representing a set of properties or methods common to objects of one type.
What is the root class from which every class extends?
The Object Class.
What are the primitive data types in Java?
The primitive data types are:
* byte
* long
* int
* double
* char
* float
* short
* boolean
Where are Strings stored in Java?
In a separate memory location in the heap known as the String Constant pool.
Explain the difference between stack and heap.
Stack is used for storing a collection of objects based on LIFO, while heap stores Java objects and can increase or decrease in size during runtime.
Are variable references stored on the stack or heap?
Local and static variable references are stored in the stack; Java objects are stored within the heap.
What is a stack frame?
Contains the state of one Java method invocation and is created when a function is called.
What are annotations in Java?
Used to provide supplementary information about a program without changing its actions, helping to associate metadata with program elements.
What is a POJO?
Plain Old Java Object, a Java object not bound by special restrictions, used for increasing readability and reusability.
What is a bean in Java?
A special POJO with restrictions, requiring access through getters and setters and encapsulating multiple objects.
Can you force garbage collection in Java?
No, but you can make an object eligible for garbage collection by severing its connection with variables.
Why are strings immutable in Java?
Because String objects are cached, and changes could affect multiple clients sharing the same string.
What is the difference between String, StringBuilder, and StringBuffer?
String is immutable; StringBuilder and StringBuffer are mutable. StringBuffer is thread-safe, while StringBuilder is not.
What are the variable scopes in Java?
The three types of variable scopes are:
* Local
* Instance
* Static
What are access modifiers in Java?
Keywords used to set the accessibility of classes, constructors, methods, and other members.
Types include private, public, protected, and default.
What are non-access modifiers in Java?
Keywords that notify the JVM about class behavior, methods, or variables.