Java OOP Notes
Java OOP Notes
2. Internet
- A global network that connects computers, allowing them to share data and resources.
- Protocols like HTTP and TCP/IP define the communication between systems on the internet.
- Java is widely used for web-based applications due to its portability (can run on any platform with a
JVM).
- Java Applets (now deprecated) were once used to run small programs within browsers.
- Advantages:
- Input: Reading data from the user, typically using Scanner class (Scanner sc = new
Scanner(System.in);).
- Output: Displaying data to the user, using System.out.println() for console output.
- Expressions: Combinations of variables, operators, and values that evaluate to a single value.
7. Flow of Control
- Loops: for, while, do-while loops control the repeated execution of code.
8. Local Variables
- Variables declared within a method and accessible only within that method.
9. Overloading
- Defining multiple methods with the same name but different parameter lists.
Example:
- Pass by Value: Java passes parameters by value, meaning it passes a copy of the variable to the
method.
11. this Pointer
- Refers to the current object instance. It helps to distinguish between instance variables and local
Example:
12. Abstraction
Example: Using a Car object without knowing the details of its internal engine mechanics.
- Class: Blueprint for creating objects, defining properties (fields) and methods (functions).
14. Encapsulation
- Wrapping data (variables) and methods into a single unit (class) and restricting access using
- Keeping details of an object's implementation hidden from the user to reduce complexity.
18. Polymorphism
- The ability of a method to do different things based on the object that it is acting upon.
- Method Overriding: Subclass provides a specific implementation of a method already defined in its
superclass.
19. Inheritance
- A class (subclass) inherits properties and behaviors (methods) from another class (superclass).
- Handling: Using try, catch, finally blocks to handle exceptions and prevent the program from
crashing.
- Cohesion: How well the elements within a module/class belong together. Aim for high cohesion.
- Involves identifying the objects and defining their relationships and interactions.
- Process: Analyze the requirements, explore the design options, and create a solution.