What is Java?
-
Java is a high-level, object-oriented, class-based programming language.
-
Developed by James Gosling at Sun Microsystems in 1995.
-
Java follows the principle: “Write Once, Run Anywhere” (WORA).
📌 Key Features of Java
Feature | Description |
---|---|
Platform Independent | Runs on JVM (Java Virtual Machine) |
Object-Oriented | Based on objects, classes, and inheritance |
Simple & Secure | Easy to learn with secure memory management |
Robust & Reliable | Strong exception handling |
Multithreaded | Supports concurrent execution |
Portable | Runs on any OS with JVM |
Compiled + Interpreted | Uses both compiler and interpreter |
🧱 Structure of a Java Program
🔍 Explanation:
-
class Hello
– Declares a class -
main()
– Entry point of any Java program -
System.out.println()
– Prints output to console
📚 Basic Concepts
1. Data Types
2. Operators
🔁 Control Statements
If-else
Switch
Loops
🔤 Functions (Methods)
🧠 Object-Oriented Concepts
Concept | Description |
---|---|
Class | Blueprint for creating objects |
Object | Instance of a class |
Inheritance | One class inherits another |
Polymorphism | Same name, different behaviors |
Encapsulation | Wrapping data and code together |
Abstraction | Hiding internal implementation |
Example of Class & Object:
📦 Packages and Import
🔐 Exception Handling
🧩 Arrays and Strings
Arrays
Strings
🌍 Practical Applications of Java
Area | Examples |
---|---|
Web Applications | Spring, JSP |
Mobile Apps | Android development |
Desktop Software | Swing, JavaFX |
Enterprise Apps | Banking systems |
Game Development | 2D/3D games |
Embedded Systems | Smart devices |
❓ Frequently Asked MCQs
-
Who developed Java?
a) Brendan Eich
b) Bjarne Stroustrup
c) James Gosling ✅
d) Dennis Ritchie -
Which of these is not a Java keyword?
a) class
b) public
c) integer ✅
d) static -
Java is:
a) Compiled only
b) Interpreted only
c) Both compiled and interpreted ✅
d) None -
Which method is the entry point of a Java program?
a) start()
b) init()
c) main() ✅
d) run() -
Which keyword is used to inherit a class in Java?
a) implements
b) extends ✅
c) include
d) inherit
📌 Important Points for Exams
-
.java
is the source file,.class
is the compiled bytecode. -
Java uses automatic garbage collection.
-
JDK = Java Development Kit (contains JRE + compiler)
-
JRE = Java Runtime Environment
-
JVM = Java Virtual Machine (executes bytecode)
📝 Conclusion
Java is one of the most powerful, secure, and scalable languages, widely used for enterprise, Android, and web development. It’s essential for OOP, backend programming, and job interviews.