Summary of Java OOPs Concepts

Concept Description Achieved Using
Encapsulation Hiding data inside a class and exposing controlled access Private variables, getters & setters
Abstraction Hiding implementation details, showing only functionality Abstract classes & interfaces
Inheritance Child class inherits properties and behaviors of parent class extends keyword
Polymorphism Methods behaving differently based on input or object type Method Overloading & Overriding
  1. Missing Semicolon (;)

The compiler error says:

Home.java:5: error: ';' expected
System.out.println("welcome to java")

🔹 This means that your System.out.println() statement is missing a semicolon (;) at the end.

Image description

2.The error expected in your Java code means that your class declaration is incomplete or incorrect.
Possible Causes of the Error

** Missing Class Name**

public class // ❌ Missing class name
{
public static void main(String[] args) {
System.out.println("welcome to java");
}
}
Image description

3.The error in your Java code is:

Home.java:5: error: package system does not exist
system.out.println("welcome to java");
^
1 error

Cause of the Error

  • Java is case-sensitive, and the correct class name is System, not system.

  • You wrote system.out.println("welcome to java"); with a lowercase "s".

  • Java doesn't recognize system as a valid package, so it throws the error:
    "package system does not exist".

Image description

4.Cause of the Error
Typo in System.out.println

  • You wrote System.outprintln("welcome to java");

  • Missing a dot (.) between out and println

  • Java is case-sensitive, and System.out.println is the correct syntax

Image description
Incorrect Code (Error)
public class Home {
public static void main(String[] args) {
System.outprintln("welcome to java"); // ❌ Missing dot (.)
}
}