Java Terms and Their Simple Explanations
Java Terms and Their Simple Explanations
---
1. **Class**:
- A blueprint to create objects.
- Example: A `Car` class defines what properties (color, brand) and actions
(start, stop) a car can have.
2. **Object**:
- An instance of a class; the actual thing created from the blueprint.
- Example: Your car is an object of the `Car` class.
3. **Method**:
- A block of code that performs a specific task (like a function in other
programming languages).
- Example: `start()` is a method that starts a car.
4. **Variable**:
- A container to store data (like numbers, words, etc.).
- Example: `int age = 25;` stores the value 25 in a variable named `age`.
5. **Constructor**:
- A special method used to create (initialize) objects.
- Example: When you create a car, the constructor sets its color, brand, etc.
6. **Interface**:
- A contract that defines what methods a class **must** implement, but it
doesn’t provide the actual code.
- Example: An interface could define `start()` and `stop()` methods that all
vehicles (cars, bikes, etc.) must have.
7. **Implements**:
- A keyword to use when a class follows an interface.
- Example: `Car implements Vehicle` means the `Car` class is following the rules
defined in the `Vehicle` interface.
8. **Extends**:
- A keyword to use when a class inherits from another class.
- Example: `ElectricCar extends Car` means `ElectricCar` gets all the properties
and methods of `Car`.
9. **Inheritance**:
- A concept where one class gets the properties and methods of another.
- Example: A `Dog` class can inherit from an `Animal` class.
10. **Polymorphism**:
- A fancy term meaning "many forms." A method can behave differently depending
on the object that calls it.
- Example: A `start()` method might start a car or a bike depending on the
object.
11. **Encapsulation**:
- Hiding the details of how something works and providing access only through
methods.
- Example: A TV has buttons to change the channel but hides the electronics
inside.
12. **Abstract Class**:
- A class that provides some methods but also leaves others for its child
classes to implement.
- Example: A `Shape` class might define common things for all shapes but leave
specific details (like drawing a circle or square) to subclasses.
13. **Static**:
- Means something belongs to the class, not individual objects.
- Example: A `static` method can be used without creating an object.
14. **Final**:
- A keyword to make something unchangeable.
- Example: A `final` variable can’t be reassigned, and a `final` class can’t be
extended.
15. **Package**:
- A folder that groups related classes together.
- Example: `java.util` is a package with utility classes like `ArrayList`.
16. **Exception**:
- An error that occurs during program execution.
- Example: Dividing a number by zero throws an exception.
17. **Try-Catch**:
- A way to handle exceptions (errors) gracefully without crashing the program.
- Example: If dividing by zero occurs, a `catch` block can show an error
message.
18. **Array**:
- A collection of items of the same type stored in a single variable.
- Example: `int[] numbers = {1, 2, 3};` stores 3 numbers.
19. **Loop**:
- A way to repeat code until a condition is met.
- Example: A `for` loop prints numbers from 1 to 10.
20. **Keyword**:
- Reserved words in Java that have a special purpose.
- Example: `class`, `public`, `static`, `final`.
26. **Stream**:
- A way to process collections (like arrays or lists) in a functional style.
- Example: Filtering even numbers from a list.
32. **Overloading**:
- Same method name but with different parameters.
- Example: `add(int a, int b)` and `add(double a, double b)`.
33. **Overriding**:
- A subclass provides a new implementation for a method from its parent class.
34. **Serialization**:
- Saving the state of an object to a file.
35. **Deserialization**:
- Restoring the state of an object from a file.
---
These terms will make more sense as you encounter examples and practice! If
something is unclear, let me know, and I can explain further. 😊