diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..7bc07ec
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Environment-dependent path to Maven home directory
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000..2d938fe
--- /dev/null
+++ b/.idea/checkstyle-idea.xml
@@ -0,0 +1,16 @@
+
+
+
+ 10.26.0
+ JavaOnly
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/material_theme_project_new.xml b/.idea/material_theme_project_new.xml
new file mode 100644
index 0000000..98e1460
--- /dev/null
+++ b/.idea/material_theme_project_new.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..89ee753
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..75dfb3d
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..c995aa5
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.debug.settings.onBuildFailureProceed": true
+}
\ No newline at end of file
diff --git a/01_Basic/HelloWorld.class b/01_Basic/HelloWorld.class
new file mode 100644
index 0000000..65257ff
Binary files /dev/null and b/01_Basic/HelloWorld.class differ
diff --git a/01_Basic/HelloWorld.java b/01_Basic/HelloWorld.java
new file mode 100644
index 0000000..70fd330
--- /dev/null
+++ b/01_Basic/HelloWorld.java
@@ -0,0 +1,5 @@
+public class HelloWorld {
+ public static void main(String[] args) {
+ System.out.println("Hello, World!");
+ }
+}
diff --git a/01_Basic/Practice-Set/BioPrinter.class b/01_Basic/Practice-Set/BioPrinter.class
new file mode 100644
index 0000000..7dcd840
Binary files /dev/null and b/01_Basic/Practice-Set/BioPrinter.class differ
diff --git a/01_Basic/Practice-Set/BioPrinter.java b/01_Basic/Practice-Set/BioPrinter.java
new file mode 100644
index 0000000..f6972cf
--- /dev/null
+++ b/01_Basic/Practice-Set/BioPrinter.java
@@ -0,0 +1,29 @@
+import java.util.Scanner;
+public class BioPrinter {
+ public static void main(String[] args) {
+ // Scanner object for taking input
+ Scanner input = new Scanner(System.in);
+
+ // Asking for user's name
+ System.out.print("Enter your name: ");
+ String name = input.nextLine();
+
+ // Asking for user's age
+ System.out.print("Enter your age: ");
+ int age = input.nextInt();
+ input.nextLine(); // Consume the leftover newline
+
+ // Asking for user's hobby
+ System.out.print("Enter your hobby: ");
+ String hobby = input.nextLine();
+
+ // Displaying the personalized bio
+ System.out.println("\n--- Your Personalized Bio ---");
+ System.out.println("Hey there! I'm " + name + ".");
+ System.out.println("I'm " + age + " years old and I absolutely love " + hobby + "!");
+ System.out.println("Nice to meet you! ๐");
+
+ // Closing the scanner
+ input.close();
+ }
+};
\ No newline at end of file
diff --git a/05_ControlStatment/SwitchDemo.java b/05_ControlStatment/SwitchDemo.java
index 0e10bb1..7a9aa1b 100644
--- a/05_ControlStatment/SwitchDemo.java
+++ b/05_ControlStatment/SwitchDemo.java
@@ -2,30 +2,15 @@ public class SwitchDemo {
public static void main(String[] args) {
int day = 3;
- switch(day) {
- case 1:
- System.out.println("Monday");
- break;
- case 2:
- System.out.println("Tuesday");
- break;
- case 3:
- System.out.println("Wednesday");
- break;
- case 4:
- System.out.println("Thursday");
- break;
- case 5:
- System.out.println("Friday");
- break;
- case 6:
- System.out.println("Saturday");
- break;
- case 7:
- System.out.println("Sunday");
- break;
- default: // Completed default case
- System.out.println("Invalid day");
+ switch (day) {
+ case 1 -> System.out.println("Monday");
+ case 2 -> System.out.println("Tuesday");
+ case 3 -> System.out.println("Wednesday");
+ case 4 -> System.out.println("Thursday");
+ case 5 -> System.out.println("Friday");
+ case 6 -> System.out.println("Saturday");
+ case 7 -> System.out.println("Sunday");
+ default -> System.out.println("Invalid day");
}
}
}
\ No newline at end of file
diff --git a/06_Methods/OperatorOverloading.java b/06_Methods/OperatorOverloading.java
index b4e7c13..5bea44a 100644
--- a/06_Methods/OperatorOverloading.java
+++ b/06_Methods/OperatorOverloading.java
@@ -6,16 +6,16 @@ public static void main(String[] args) {
}
public static int math(int a, int b, char operation) {
- switch (operation) {
- case '+': return a + b;
- case '*': return a * b;
- case '/':
+ return switch (operation) {
+ case '+' -> a + b;
+ case '*' -> a * b;
+ case '/' -> {
if (b == 0) {
throw new ArithmeticException("Division by zero is not allowed");
}
- return a / b;
- default:
- throw new IllegalArgumentException("Unsupported operation: " + operation);
- }
+ yield a / b;
+ }
+ default -> throw new IllegalArgumentException("Unsupported operation: " + operation);
+ };
}
}
diff --git a/07_ArrayAndString/ThreeDArray.java b/07_ArrayAndString/TwoDArrayy.java
similarity index 93%
rename from 07_ArrayAndString/ThreeDArray.java
rename to 07_ArrayAndString/TwoDArrayy.java
index b0a866b..4a4c580 100644
--- a/07_ArrayAndString/ThreeDArray.java
+++ b/07_ArrayAndString/TwoDArrayy.java
@@ -1,4 +1,4 @@
-public class TwoDArray {
+public class TwoDArrayy {
public static void main(String[] args) {
int [][]matrix = {
{1, 2, 3},
diff --git a/08_OOPs/08_OOPs.iml b/08_OOPs/08_OOPs.iml
new file mode 100644
index 0000000..2798ae4
--- /dev/null
+++ b/08_OOPs/08_OOPs.iml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/08_OOPs/Abstraction/Animal.class b/08_OOPs/Abstraction/Animal.class
new file mode 100644
index 0000000..c97dea0
Binary files /dev/null and b/08_OOPs/Abstraction/Animal.class differ
diff --git a/08_OOPs/Abstraction/Dog.class b/08_OOPs/Abstraction/Dog.class
new file mode 100644
index 0000000..a10d435
Binary files /dev/null and b/08_OOPs/Abstraction/Dog.class differ
diff --git a/08_OOPs/Abstraction/Main.class b/08_OOPs/Abstraction/Main.class
new file mode 100644
index 0000000..aae02df
Binary files /dev/null and b/08_OOPs/Abstraction/Main.class differ
diff --git a/08_OOPs/Abstraction/Main.java b/08_OOPs/Abstraction/Main.java
new file mode 100644
index 0000000..e642be3
--- /dev/null
+++ b/08_OOPs/Abstraction/Main.java
@@ -0,0 +1,27 @@
+// Abstract class
+abstract class Animal {
+ // Abstract method (no body)
+ abstract void sound();
+
+ // Regular method
+ void sleep() {
+ System.out.println("Animal is sleeping...๐ด");
+ }
+}
+
+// Subclass
+class Dog extends Animal {
+ // Providing implementation of abstract method
+ void sound() {
+ System.out.println("Dog barks: Woof Woof! ๐ถ");
+ }
+}
+
+// Main class to run
+public class Main {
+ public static void main(String[] args) {
+ Animal myDog = new Dog(); // Polymorphism + Abstraction
+ myDog.sound(); // Woof Woof!
+ myDog.sleep(); // Sleeping...
+ }
+}
diff --git a/08_OOPs/Abstraction/Notes.java b/08_OOPs/Abstraction/Notes.java
new file mode 100644
index 0000000..517dedd
--- /dev/null
+++ b/08_OOPs/Abstraction/Notes.java
@@ -0,0 +1 @@
+//Abstraction means hiding the complex stuff and showing only the essentials.
\ No newline at end of file
diff --git a/08_OOPs/Encapsulation/Basic.class b/08_OOPs/Encapsulation/Basic.class
new file mode 100644
index 0000000..fcf1290
Binary files /dev/null and b/08_OOPs/Encapsulation/Basic.class differ
diff --git a/08_OOPs/Encapsulation/Basic.java b/08_OOPs/Encapsulation/Basic.java
new file mode 100644
index 0000000..284ab8e
--- /dev/null
+++ b/08_OOPs/Encapsulation/Basic.java
@@ -0,0 +1,62 @@
+// data hiding in java
+// for the purpose of restricting direct access to some of the objects components
+// private variables (private) keyword
+// public method (getter / setter)
+// why encapsulation
+// 1 data security
+// 2 control
+// 3 code maintainability
+
+
+// Getter method
+// public String Getname (){
+// return name ;
+// } it's the syntax
+// getter method allows controlled access to a private variable
+// Getter provides " read only " access to the name variable
+
+// Setter Method -
+// this is also a public method , which allowed controlled modification of a parivate variable
+// this . name = name ;
+// private parameter
+
+class Person {
+ private String name;
+ private int age;
+
+ // getter method
+ public String getName() {
+ return name;
+ }
+
+ // setter method
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ // setter for age
+ public void setAge(int age) {
+ if (age> 0) {
+ this.age = age;
+ } else {
+ System.out.println("Age cannot be 0 or negative");
+ }
+ }
+
+ public void display() {
+ System.out.println("Name: " + name + ", Age: " + age);
+ }
+}
+
+public class Basic {
+ public static void main(String[] args) {
+ Person p = new Person();
+ p.setName("John");
+ p.setAge(25);
+ p.display();
+ }
+}
\ No newline at end of file
diff --git a/08_OOPs/Encapsulation/GetterMethod.java b/08_OOPs/Encapsulation/GetterMethod.java
new file mode 100644
index 0000000..d24e8ed
--- /dev/null
+++ b/08_OOPs/Encapsulation/GetterMethod.java
@@ -0,0 +1,5 @@
+
+
+public class GetterMethod {
+
+}
diff --git a/08_OOPs/Second/Animal.class b/08_OOPs/Second/Animal.class
new file mode 100644
index 0000000..f5729c2
Binary files /dev/null and b/08_OOPs/Second/Animal.class differ
diff --git a/08_OOPs/Second/Animals.class b/08_OOPs/Second/Animals.class
new file mode 100644
index 0000000..b89f6bf
Binary files /dev/null and b/08_OOPs/Second/Animals.class differ
diff --git a/08_OOPs/Second/Animals.java b/08_OOPs/Second/Animals.java
new file mode 100644
index 0000000..503171b
--- /dev/null
+++ b/08_OOPs/Second/Animals.java
@@ -0,0 +1,27 @@
+class Animal {
+ void eat() {
+ System.out.println("animal eats");
+ }
+}
+
+class Dog extends Animal {
+ void bark() {
+ System.out.println("doggy");
+ }
+}
+
+class Puppy extends Dog {
+ void Weep() {
+ System.out.println("Weeping");
+ }
+}
+
+public class Animals {
+ public static void main(String[] args) {
+ Puppy Tom = new Puppy();
+
+ Tom.Weep();
+ Tom.bark();
+ Tom.eat();
+ }
+};
diff --git a/08_OOPs/Second/Calculator.class b/08_OOPs/Second/Calculator.class
new file mode 100644
index 0000000..68e6e71
Binary files /dev/null and b/08_OOPs/Second/Calculator.class differ
diff --git a/08_OOPs/Second/Car.class b/08_OOPs/Second/Car.class
new file mode 100644
index 0000000..31a1de8
Binary files /dev/null and b/08_OOPs/Second/Car.class differ
diff --git a/08_OOPs/Second/Dog.class b/08_OOPs/Second/Dog.class
new file mode 100644
index 0000000..475d989
Binary files /dev/null and b/08_OOPs/Second/Dog.class differ
diff --git a/08_OOPs/Second/HelloJava.class b/08_OOPs/Second/HelloJava.class
new file mode 100644
index 0000000..7f5ed08
Binary files /dev/null and b/08_OOPs/Second/HelloJava.class differ
diff --git a/08_OOPs/Second/HelloJava.java b/08_OOPs/Second/HelloJava.java
new file mode 100644
index 0000000..688317d
--- /dev/null
+++ b/08_OOPs/Second/HelloJava.java
@@ -0,0 +1,21 @@
+class Calculator {
+ int result = 0;
+
+ Calculator add(int val) {
+ result += val;
+ return this;
+ }
+ Calculator multiply(int val) {
+ result += val;
+ return this;
+ }
+ void show() {
+ System.out.println("Result: " + result);
+ }
+}
+public class HelloJava {
+ public static void main(String[] args) {
+ Calculator c = new Calculator();
+ c.add(5).multiply(10).show();
+ }
+};
diff --git a/08_OOPs/Second/Hero.class b/08_OOPs/Second/Hero.class
new file mode 100644
index 0000000..258ed27
Binary files /dev/null and b/08_OOPs/Second/Hero.class differ
diff --git a/08_OOPs/Second/Hero.java b/08_OOPs/Second/Hero.java
new file mode 100644
index 0000000..dfdd879
--- /dev/null
+++ b/08_OOPs/Second/Hero.java
@@ -0,0 +1,18 @@
+class Animal {
+ void eat() {
+ System.out.println("This animal eats foods");
+ }
+}
+class Dog extends Animal {
+ void bark() {
+ System.out.println("The dog barks");
+ }
+}
+
+public class Hero {
+ public static void main(String[] args) {
+ Dog d = new Dog();
+ d.eat();
+ d.bark();
+ }
+};
diff --git a/08_OOPs/Second/Hyena.class b/08_OOPs/Second/Hyena.class
new file mode 100644
index 0000000..cba0381
Binary files /dev/null and b/08_OOPs/Second/Hyena.class differ
diff --git a/08_OOPs/Second/Puppy.class b/08_OOPs/Second/Puppy.class
new file mode 100644
index 0000000..9560513
Binary files /dev/null and b/08_OOPs/Second/Puppy.class differ
diff --git a/08_OOPs/Second/Sherkhan.class b/08_OOPs/Second/Sherkhan.class
new file mode 100644
index 0000000..f980752
Binary files /dev/null and b/08_OOPs/Second/Sherkhan.class differ
diff --git a/08_OOPs/Second/Stud.class b/08_OOPs/Second/Stud.class
new file mode 100644
index 0000000..78f3335
Binary files /dev/null and b/08_OOPs/Second/Stud.class differ
diff --git a/08_OOPs/Second/Stud.java b/08_OOPs/Second/Stud.java
new file mode 100644
index 0000000..33dd24d
--- /dev/null
+++ b/08_OOPs/Second/Stud.java
@@ -0,0 +1,20 @@
+class Student {
+ int id;
+ String name;
+
+ Student(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ void display() {
+ System.out.println("ID: " + id + ", Name: " + name);
+ }
+}
+// class name == file name
+public class Stud {
+ public static void main(String[] args) {
+ Student s1 = new Student(101, "Piyush");
+ s1.display();
+ }
+}
diff --git a/08_OOPs/Second/Student.class b/08_OOPs/Second/Student.class
index 4642508..eb625de 100644
Binary files a/08_OOPs/Second/Student.class and b/08_OOPs/Second/Student.class differ
diff --git a/08_OOPs/Second/Student.java b/08_OOPs/Second/Student.java
index ea2879b..1ef167a 100644
--- a/08_OOPs/Second/Student.java
+++ b/08_OOPs/Second/Student.java
@@ -1,12 +1,16 @@
-public class Student {
+class Stud {
String name;
int age;
- Student() {
+ // calling constructor inside constructor
+ /**
+ *
+ */
+ Stud() {
this("Unknown", 0);
}
- Student(String name, int age) {
+ Stud(String name, int age) {
this.name = name;
this.age = age;
}
@@ -14,12 +18,18 @@ public class Student {
void display() {
System.out.println("Name: " + name + " Age: " + age);
}
+}
+class StudentTest {
public static void main(String[] args) {
- Student s1 = new Student();
- Student s2 = new Student("Arjun", 22);
+ Stud s1 = new Stud();
+ Stud s2 = new Stud("Arjun", 22);
s1.display();
s2.display();
+
+ // Explicitly use StudentTest to avoid "never used" warning
+ StudentTest test = new StudentTest();
}
-};
+
+}
diff --git a/08_OOPs/Second/SuperAnimal.class b/08_OOPs/Second/SuperAnimal.class
new file mode 100644
index 0000000..1eb4440
Binary files /dev/null and b/08_OOPs/Second/SuperAnimal.class differ
diff --git a/08_OOPs/Second/SuperAnimal.java b/08_OOPs/Second/SuperAnimal.java
new file mode 100644
index 0000000..8f5fa49
--- /dev/null
+++ b/08_OOPs/Second/SuperAnimal.java
@@ -0,0 +1,21 @@
+class Animal {
+ String name;
+
+ Animal(String name) {
+ this.name = name;
+ System.out.println("Animal: " + name);
+ }
+}
+
+class Dog extends Animal {
+ Dog(String name) {
+ super(name);
+ System.out.println("Dog Control");
+ }
+}
+
+public class SuperAnimal {
+ public static void main(String[] args) {
+ Dog tom = new Dog("Buddy");
+ }
+}
diff --git a/08_OOPs/Second/SuperAnimalfour.class b/08_OOPs/Second/SuperAnimalfour.class
new file mode 100644
index 0000000..9f2535b
Binary files /dev/null and b/08_OOPs/Second/SuperAnimalfour.class differ
diff --git a/08_OOPs/Second/SuperAnimalfour.java b/08_OOPs/Second/SuperAnimalfour.java
new file mode 100644
index 0000000..6bc9002
--- /dev/null
+++ b/08_OOPs/Second/SuperAnimalfour.java
@@ -0,0 +1,18 @@
+class Hyena {
+ Hyena() {
+ System.out.println("Hyena Here");
+ }
+}
+
+class Sherkhan extends Hyena {
+ Sherkhan() {
+ // super() is called implicitly
+ System.out.println("Sherkhan Here");
+ }
+}
+
+public class SuperAnimalfour {
+ public static void main(String[] args) {
+ Sherkhan ChildOne = new Sherkhan();
+ }
+}
diff --git a/08_OOPs/Second/SuperAnimalthree.class b/08_OOPs/Second/SuperAnimalthree.class
new file mode 100644
index 0000000..3bc0c3b
Binary files /dev/null and b/08_OOPs/Second/SuperAnimalthree.class differ
diff --git a/08_OOPs/Second/SuperAnimalthree.java b/08_OOPs/Second/SuperAnimalthree.java
new file mode 100644
index 0000000..3a04710
--- /dev/null
+++ b/08_OOPs/Second/SuperAnimalthree.java
@@ -0,0 +1,18 @@
+class Animal {
+ void eat() {
+ System.out.println("Animal eats food");
+ }
+}
+class Dog extends Animal {
+ void eat() {
+ super.eat();
+ System.out.println("Dog eats Bones");
+ }
+}
+
+public class SuperAnimalthree {
+ public static void main(String[] args) {
+ Dog tommy = new Dog();
+ tommy.eat();
+ }
+}
diff --git a/08_OOPs/Second/SuperAnimaltwo.class b/08_OOPs/Second/SuperAnimaltwo.class
new file mode 100644
index 0000000..5b73570
Binary files /dev/null and b/08_OOPs/Second/SuperAnimaltwo.class differ
diff --git a/08_OOPs/Second/SuperAnimaltwo.java b/08_OOPs/Second/SuperAnimaltwo.java
new file mode 100644
index 0000000..82046c6
--- /dev/null
+++ b/08_OOPs/Second/SuperAnimaltwo.java
@@ -0,0 +1,19 @@
+class Animal {
+ String type = "Generic Animal";
+}
+
+class Dog extends Animal {
+ String type = "Dog";
+
+ void printing() {
+ System.out.println("Sub Class Type: " + type);
+ System.out.println("Parent Class Type: " + super.type);
+ }
+}
+
+public class SuperAnimaltwo {
+ public static void main(String[] args) {
+ Dog myDog = new Dog();
+ myDog.printing();
+ }
+}
diff --git a/08_OOPs/Second/Vehical.class b/08_OOPs/Second/Vehical.class
new file mode 100644
index 0000000..48f543a
Binary files /dev/null and b/08_OOPs/Second/Vehical.class differ
diff --git a/08_OOPs/Second/Vehicals.class b/08_OOPs/Second/Vehicals.class
new file mode 100644
index 0000000..a31d676
Binary files /dev/null and b/08_OOPs/Second/Vehicals.class differ
diff --git a/08_OOPs/Second/Vehicals.java b/08_OOPs/Second/Vehicals.java
new file mode 100644
index 0000000..8296c57
--- /dev/null
+++ b/08_OOPs/Second/Vehicals.java
@@ -0,0 +1,19 @@
+class Vehical {
+ void start() {
+ System.out.println("Vehical starts");
+ }
+}
+class Car extends Vehical {
+ void drive() {
+ System.out.println("Car driving");
+ }
+}
+
+public class Vehicals {
+ public static void main(String[] args) {
+ Car Toyota = new Car();
+
+ Toyota.start();
+ Toyota.drive();
+ }
+};
diff --git a/08_OOPs/Third/Animal.class b/08_OOPs/Third/Animal.class
new file mode 100644
index 0000000..640e53e
Binary files /dev/null and b/08_OOPs/Third/Animal.class differ
diff --git a/08_OOPs/Third/Calculator.class b/08_OOPs/Third/Calculator.class
new file mode 100644
index 0000000..3cff068
Binary files /dev/null and b/08_OOPs/Third/Calculator.class differ
diff --git a/08_OOPs/Third/CalculatorOverloading.class b/08_OOPs/Third/CalculatorOverloading.class
new file mode 100644
index 0000000..902b009
Binary files /dev/null and b/08_OOPs/Third/CalculatorOverloading.class differ
diff --git a/08_OOPs/Third/CalculatorOverloading.java b/08_OOPs/Third/CalculatorOverloading.java
new file mode 100644
index 0000000..1efcac1
--- /dev/null
+++ b/08_OOPs/Third/CalculatorOverloading.java
@@ -0,0 +1,24 @@
+// File: CalculatorOverloading.java
+
+public class CalculatorOverloading {
+
+ public int add(int a, int b) {
+ return a + b;
+ }
+
+ public double add(double a, double b) {
+ return a + b;
+ }
+
+ public int add(int a, int b, int c) {
+ return a + b + c;
+ }
+
+ public static void main(String[] args) {
+ CalculatorOverloading calc = new CalculatorOverloading();
+
+ System.out.println("add(int, int): " + calc.add(10, 20));
+ System.out.println("add(double, double): " + calc.add(15.5, 20.3));
+ System.out.println("add(int, int, int): " + calc.add(1, 2, 3));
+ }
+}
diff --git a/08_OOPs/Third/Dog.class b/08_OOPs/Third/Dog.class
new file mode 100644
index 0000000..1587662
Binary files /dev/null and b/08_OOPs/Third/Dog.class differ
diff --git a/08_OOPs/Third/MethodOverloading.class b/08_OOPs/Third/MethodOverloading.class
new file mode 100644
index 0000000..708f677
Binary files /dev/null and b/08_OOPs/Third/MethodOverloading.class differ
diff --git a/08_OOPs/Third/MethodOverloading.java b/08_OOPs/Third/MethodOverloading.java
new file mode 100644
index 0000000..006cab0
--- /dev/null
+++ b/08_OOPs/Third/MethodOverloading.java
@@ -0,0 +1,21 @@
+class Calculator {
+
+ int add(int a, int b) {
+ return a + b;
+ }
+ double add(double a, double b){
+ return a + b;
+ }
+ int add(int a, int b, int c){
+ return a + b + c;
+ }
+}
+
+public class MethodOverloading {
+public static void main(String[] args) {
+ Calculator c1 = new Calculator();
+ System.out.println(c1.add(2, 3));
+ System.out.println(c1.add(2.5, 3.5));
+ System.out.println(c1.add(2, 3, 7));
+}
+};
diff --git a/08_OOPs/Third/MyCar.java b/08_OOPs/Third/MyCar.java
new file mode 100644
index 0000000..3fb46e9
--- /dev/null
+++ b/08_OOPs/Third/MyCar.java
@@ -0,0 +1,24 @@
+final class Vehical {
+ final String brand = "Generic";
+ void Describe() {
+ System.out.println("Brand" + brand);
+ }
+}
+class Car extends Vehical {
+ String model;
+ Car (String model) {
+ this.model;
+ }
+ @ Override
+ void Describe() {
+ super.Describe();
+ System.out.println("Model: " + model);
+ }
+}
+public class MyCar {
+ public static void main(String[] args) {
+ Car Toyota = new Car("Sedan");
+ Toyota.Describe();
+ }
+}
+
diff --git a/08_OOPs/Third/MyWorld.class b/08_OOPs/Third/MyWorld.class
new file mode 100644
index 0000000..6efc735
Binary files /dev/null and b/08_OOPs/Third/MyWorld.class differ
diff --git a/08_OOPs/Third/MyWorld.java b/08_OOPs/Third/MyWorld.java
new file mode 100644
index 0000000..36817cd
--- /dev/null
+++ b/08_OOPs/Third/MyWorld.java
@@ -0,0 +1,17 @@
+class Animal {
+ void Sound() {
+ System.out.println("Animal makes sound");
+ }
+}
+class Dog extends Animal {
+ @ Override
+ void Sound() {
+ System.out.println("Dog barks: ");
+ }
+}
+public class MyWorld {
+ public static void main(String[] args) {
+ Animal a = new Dog();
+ a.Sound();
+ }
+}
\ No newline at end of file
diff --git a/08_OOPs/Third/Override.class b/08_OOPs/Third/Override.class
new file mode 100644
index 0000000..2748d2b
Binary files /dev/null and b/08_OOPs/Third/Override.class differ
diff --git a/08_OOPs/Third/Override.java b/08_OOPs/Third/Override.java
new file mode 100644
index 0000000..af908d1
--- /dev/null
+++ b/08_OOPs/Third/Override.java
@@ -0,0 +1,29 @@
+class Person {
+ String name;
+ Person(String name) {
+ this.name = name;
+ }
+ void Display() {
+ System.out.println("Person: " + name);
+ }
+}
+class Student extends Person {
+ double grade;
+
+ Student(String name, double grade) {
+ super(name);
+ this.grade = grade;
+ }
+ void Display() {
+ System.out.println("Student: " + name + "Grade: " + grade);
+ }
+}
+
+public class Override {
+ public static void main(String[] args) {
+ Person P = new Person("Alice");
+ Student S = new Student("Bod", 82.5);
+ P.Display();
+ S.Display();
+ }
+}
diff --git a/08_OOPs/Third/Person.class b/08_OOPs/Third/Person.class
new file mode 100644
index 0000000..329f9a8
Binary files /dev/null and b/08_OOPs/Third/Person.class differ
diff --git a/08_OOPs/Third/Student.class b/08_OOPs/Third/Student.class
new file mode 100644
index 0000000..6f9f9c9
Binary files /dev/null and b/08_OOPs/Third/Student.class differ
diff --git a/09_ArrayAndString/ArrayExample.class b/09_ArrayAndString/ArrayExample.class
new file mode 100644
index 0000000..a8539d2
Binary files /dev/null and b/09_ArrayAndString/ArrayExample.class differ
diff --git a/09_ArrayAndString/ArrayExample.java b/09_ArrayAndString/ArrayExample.java
new file mode 100644
index 0000000..ae31d18
--- /dev/null
+++ b/09_ArrayAndString/ArrayExample.java
@@ -0,0 +1,15 @@
+public class ArrayExample {
+ public static void main(String[] args) {
+ // Declare and initialize an array of integers
+ int[] numbers = {10, 20, 30, 40, 50};
+
+ // Access elements
+ System.out.println("First number: " + numbers[0]); // Outputs 10
+
+ // Loop through the array
+ System.out.println("All numbers:");
+ for(int i = 0; i < numbers.length; i++) { + System.out.println(numbers[i]); + } + } +} diff --git a/09_ArrayAndString/ArrayFouth.class b/09_ArrayAndString/ArrayFouth.class new file mode 100644 index 0000000..c050e56 Binary files /dev/null and b/09_ArrayAndString/ArrayFouth.class differ diff --git a/09_ArrayAndString/ArrayFouth.java b/09_ArrayAndString/ArrayFouth.java new file mode 100644 index 0000000..49c63dc --- /dev/null +++ b/09_ArrayAndString/ArrayFouth.java @@ -0,0 +1,19 @@ + +public class ArrayFouth { + + public static void main(String[] args) { + // S-1-Create an object array with diff. data type + + Object[] mixedArray = {123, "Java", 45.67, true, 'A'}; + // S-2 Conter each element to string, + + for (Object element : mixedArray) { + String Str = element.toString(); + System.out.println("Convert to string: " + Str); + } + } +} + +// 1.) object mixedarray = { } => this create an array that can hold any type of data , since everything in java extends object
+// 2.) elements.toString() => every class in java inherits the toString() method from the object class
+ // 3.) primitive values like int , boolean etc , are autobased into their wrapper classes( integer , Boolean ) , which override to String() to return a readable String form
diff --git a/09_ArrayAndString/ArrayList/ArraylistDemo.java b/09_ArrayAndString/ArrayList/ArraylistDemo.java
new file mode 100644
index 0000000..317f0fa
--- /dev/null
+++ b/09_ArrayAndString/ArrayList/ArraylistDemo.java
@@ -0,0 +1,36 @@
+// Array List => DSA
+// import java.util.Array List;
+// import java.util.scanner;
+// public class ArraylistDemo{
+
+// }
+
+
+// // 1.) when you don't know what will be the size of an array & simply telling java to handle the array and its element . there comes the arraylist in the game .
+// // 2.) it is similar to vectors in c++ , in java it is the part of collections frameworks.
+
+
+// // Syntax.=>
+// Arraylist list = new Arraylist ();
+
+// here integer means what is the type of data you want to stop in the list .
+
+// add many as you want,
+// System.out.println(list.contains(34));
+// Contains f(n) => Helps you to find what are you searching for in the list.public class ArraylistDemo {
+
+// set f(n) => (index, the new value of the element);
+
+// System.out.println(lest.remove(0);
+// remove.f(n) => removing a perticular item on a particular index
+
+// for(int i = 0; i < 5; i++){ +// list.add(in.netInt()); + +// add new element as an input to the list> getting the items at any index.
+// for(int i = 0; i < 5; i++) { +// System.out.println(list.get(i)); +// } +// System.out.println(list); +// } +// } \ No newline at end of file diff --git a/09_ArrayAndString/ArrayThree.class b/09_ArrayAndString/ArrayThree.class new file mode 100644 index 0000000..1868862 Binary files /dev/null and b/09_ArrayAndString/ArrayThree.class differ diff --git a/09_ArrayAndString/ArrayThree.java b/09_ArrayAndString/ArrayThree.java new file mode 100644 index 0000000..c84d064 --- /dev/null +++ b/09_ArrayAndString/ArrayThree.java @@ -0,0 +1,20 @@ + +import java.util.Arrays; +import java.util.Scanner; + +public class ArrayThree { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + // array of string object + String[] Str = new String[4]; + for(int i = 0; i < Str.length; i++) { + Str [i] = in.next(); + } + System.out.println(Arrays.toString(Str)); + // after modifing the array + + Str[1] = "Laksh"; + System.out.println(Arrays.toString(Str)); + in.close(); + } +} diff --git a/09_ArrayAndString/Arraytwo.class b/09_ArrayAndString/Arraytwo.class new file mode 100644 index 0000000..306f487 Binary files /dev/null and b/09_ArrayAndString/Arraytwo.class differ diff --git a/09_ArrayAndString/Arraytwo.java b/09_ArrayAndString/Arraytwo.java new file mode 100644 index 0000000..5301a74 --- /dev/null +++ b/09_ArrayAndString/Arraytwo.java @@ -0,0 +1,18 @@ +import java.util.Scanner; +public class Arraytwo { + public static void main(String[] args) { + //taking input from the user + Scanner in = new Scanner(System.in); + int [] arr = new int [5]; + //using foor loop, + for (int i = 1; i < arr.length; i++) { + arr[i] = in.nextInt(); + } + //enhanced loop, + for (int num : arr) { + System.out.println(num + " "); + } + + + } +} diff --git a/09_ArrayAndString/Multi.java b/09_ArrayAndString/Multi.java new file mode 100644 index 0000000..e86a259 --- /dev/null +++ b/09_ArrayAndString/Multi.java @@ -0,0 +1,83 @@ +import java.util.*; + +public class Multi { + public static void main(String args[]) { + // Create a Scanner object to read input from the user + Scanner sc = new Scanner(System.in); + + // Declare a 2D array 'arr' with 3 rows but unspecified columns + int arr[][] = new int[3][]; + + // Initialize a 2D array 'arr2' with 3x3 fixed dimensions + // This creates a perfect square matrix + int arr2[][] = { + {1, 2, 3}, // First row + {4, 5, 6}, // Second row + {7, 8, 9} // Third row + }; + + // Initialize a 2D array 'arr3' with varying column lengths + // This demonstrates a jagged array (array with different column lengths) + int arr3[][] = { + {1, 2}, // First row has 2 columns + {1, 2, 3}, // Second row has 3 columns + {1, 2, 3, 4} // Third row has 4 columns + }; + + // Taking input for arr - Dynamic array creation + System.out.println("Enter elements for arr:"); + // Loop through each row + for (int i = 0; i < 3; i++) { + // Ask user for number of columns in current row + System.out.print("Enter number of columns for row " + (i + 1) + ": "); + int cols = sc.nextInt(); + // Create a new array for current row with specified number of columns + arr[i] = new int[cols]; + + // Take input for each element in the current row + System.out.println("Enter " + cols + " elements for row " + (i + 1) + ":"); + for (int j = 0; j < cols; j++) { + arr[i][j] = sc.nextInt(); + } + } + + // Print the dynamically created array 'arr' + System.out.println("Array arr:"); + // Outer loop iterates through rows + for (int i = 0; i < arr.length; i++) { + // Inner loop iterates through columns of current row + for (int j = 0; j < arr[i].length; j++) { + System.out.print(arr[i][j] + " "); + } + System.out.println(); // New line after each row + } + + // Print the fixed-size array 'arr2' + System.out.println("\nArray arr2:"); + for (int i = 0; i < arr2.length; i++) { + for (int j = 0; j < arr2[i].length; j++) { + System.out.print(arr2[i][j] + " "); + } + System.out.println(); + } + + // Print the jagged array 'arr3' + System.out.println("\nArray arr3:"); + for (int i = 0; i < arr3.length; i++) { + for (int j = 0; j < arr3[i].length; j++) { + System.out.print(arr3[i][j] + " "); + } + System.out.println(); + } + } +} + +// Additional notes about 2D arrays in Java: +// 1. When we create an array, the reference (arr) is stored in the stack while the actual elements are stored in the heap +// 2. A 2D array is essentially an array of arrays +// 3. arr.length gives the number of rows in the array +// 4. When iterating a 2D array: +// - The outer for loop iterates over each row +// - The inner for loop iterates over each column of the current row +// 5. arr[i].length is used to get the number of columns in a specific row +// - This is particularly useful for jagged arrays where different rows may have different numbers of columns \ No newline at end of file diff --git a/09_ArrayAndString/Notes.java b/09_ArrayAndString/Notes.java new file mode 100644 index 0000000..aca9d94 --- /dev/null +++ b/09_ArrayAndString/Notes.java @@ -0,0 +1,52 @@ +// Array and string + +// in java there is no pointer concept +// array is a collection of similar type of data + +// array is a collection of similar and multiple type of data +// array objects are stored in The heap memory +// Heap opject are not onctinous +// dynamic memory allocation to the place in the heap memory +// the new keyword is used to create a new object in the heap memory +//try to declare an array assigning the size , you will not get any error but you will get a runtime error +// string is a reference type datatype , now array of string pointing towards indivisual string object in java . so if nothing is assigned to the array of string then it will be null. +// String arr1[] = new String[10]; +// System.out.println(arr[0]); =====>> it will give null exception
+
+
+
+
+
+// Arrays and Strings in Java ๐
+
+// Java doesn't support pointers like C/C++.
+// But it uses references โ kind of like a "safe pointer".
+
+// โ Arrays = Collection of similar data types (NOT multiple data types)
+// โ Wrong: "array is a collection of similar and multiple type of data"
+
+// Arrays in Java are **objects**, and all objects are stored in **heap memory**.
+// Heap memory isnโt necessarily contiguous like in C, but the array itself is a continuous block.
+
+// Arrays use **dynamic memory allocation**, which means size is set at runtime using `new` keyword.
+// Example:
+int[] arr = new int[5]; // allocates space for 5 integers in heap
+
+// Note: Declaring an array with a size wonโt throw an error,
+// but accessing an element that hasn't been initialized will return the default value.
+// For objects, that's `null`. For primitives like int, it's `0`.
+
+// Let's play with a String array ๐ฏ
+String[] arr1 = new String[10];
+System.out.println(arr1[0]); // Output: null (NOT an exception)
+
+// But... if you try to access arr1[10], boom ๐ฅ
+// You'll get: ArrayIndexOutOfBoundsException
+
+// TL;DR:
+// - Arrays = same data type only
+// - Stored in heap
+// - Default values: 0 for int, null for String/objects
+// - Use `new` to create arrays
+// - Donโt go out of bounds, or Java will throw hands ๐
+
diff --git a/09_ArrayAndString/PassingFunction.class b/09_ArrayAndString/PassingFunction.class
new file mode 100644
index 0000000..135da62
Binary files /dev/null and b/09_ArrayAndString/PassingFunction.class differ
diff --git a/09_ArrayAndString/PassingFunction.java b/09_ArrayAndString/PassingFunction.java
new file mode 100644
index 0000000..2a78fa7
--- /dev/null
+++ b/09_ArrayAndString/PassingFunction.java
@@ -0,0 +1,33 @@
+
+import java.util.Arrays;
+
+public class PassingFunction {
+ static void change (int [] arr) {
+ arr[0] = 99;
+ }
+ public static void main(String[] args) {
+ int [] nums = {1, 2, 3, 4, 5, 6};
+ System.out.println(Arrays.toString(nums));
+ change(nums);
+ System.out.println(Arrays.toString(nums));
+ }
+}
+
+// 1. Strings are immutable in Java:
+// Once a String object is created, its value cannot be changed.
+// Any operation that seems to modify a string (like concatenation or replacement)
+// actually creates a new String object in memory. This ensures security and consistency,
+// especially in multi-threaded environments.
+
+// 2. Arrays are mutable in Java:
+// Arrays allow changes to their contents after creation. You can update, replace,
+// or modify individual elements within the same array object. This makes arrays
+// flexible for tasks like data manipulation or iterative processing.
+
+// 3. Mutability:
+// An object is considered "mutable" if its internal state (its data or values)
+// can be changed after it is created. If not, it is "immutable". Mutable objects
+// are useful when you need to update or modify data over time,
+// while immutable objects offer advantages like thread safety and simplicity.
+
+
diff --git a/10_String/StringBasics.class b/10_String/StringBasics.class
new file mode 100644
index 0000000..7585a0c
Binary files /dev/null and b/10_String/StringBasics.class differ
diff --git a/10_String/StringBasics.java b/10_String/StringBasics.java
new file mode 100644
index 0000000..462095a
--- /dev/null
+++ b/10_String/StringBasics.java
@@ -0,0 +1,35 @@
+import java.util.Scanner;
+
+public class StringBasics {
+ public static void main(String[] args) {
+ Scanner sc = new Scanner(System.in);
+
+ // Input string from user
+ System.out.print("Enter your name: ");
+ String name = sc.nextLine();
+
+ // Print original string
+ System.out.println("Your name is: " + name);
+
+ // String length
+ System.out.println("Length of your name: " + name.length());
+
+ // Access individual characters
+ System.out.println("First character: " + name.charAt(0));
+
+ // Concatenate strings
+ String greeting = "Hello, " + name + "!";
+ System.out.println(greeting);
+
+ // Convert to uppercase
+ System.out.println("In uppercase: " + name.toUpperCase());
+
+ // Convert to lowercase
+ System.out.println("In lowercase: " + name.toLowerCase());
+
+ // Check if name contains a letter
+ System.out.println("Does your name contain 'a'? " + name.contains("a"));
+
+ sc.close();
+ }
+}
diff --git a/10_String/StringFive.class b/10_String/StringFive.class
new file mode 100644
index 0000000..df3b5a3
Binary files /dev/null and b/10_String/StringFive.class differ
diff --git a/10_String/StringFive.java b/10_String/StringFive.java
new file mode 100644
index 0000000..8d26103
--- /dev/null
+++ b/10_String/StringFive.java
@@ -0,0 +1,34 @@
+
+public class StringFive {
+
+ public static void main(String[] args) {
+ String series = " ";
+ for (int i = 0; i < 26; i++) { + char ch = (char) ('a' + i); + series = series + ch; + } + System.out.println(series); + } +} + +// 1>
+// after first iteration -" "> "a"
+// after second iteration - "a"> "ab"
+
+// 2>
+// as we know, strings are immutable in jave one every iteration of the loop a new string object is created and the old value of the string are being copied to yhe new one.
+
+// 3>
+// This is not optimal performance ar the old objects are getting derefernced everytime i am adding a new string object.
+
+// 4>
+// Total wastage of space - a, ab, abc ---- till 26 because 26th one ends this.
+
+//5>
+// Time complexity - 0(n2)
+
+//6>
+// The only soultion to this is an data type which can allow me to modify its value??
+// -> Strings are immutable ---- now?
+// -> String Builder class in JAVA โ
+
diff --git a/10_String/StringFour.class b/10_String/StringFour.class
new file mode 100644
index 0000000..6ef2eb4
Binary files /dev/null and b/10_String/StringFour.class differ
diff --git a/10_String/StringFour.java b/10_String/StringFour.java
new file mode 100644
index 0000000..e491d1e
--- /dev/null
+++ b/10_String/StringFour.java
@@ -0,0 +1,25 @@
+import java.util.ArrayList;
+
+public class StringFour {
+ public static void main(String[] args) {
+ System.out.println('a' + 'b');
+
+ // the operator behind the scene is converting a --> ASCII values
+
+ System.out.println("a" + "b");
+
+ // here string concatenation is taking palce.
+
+ System.out.println((char)('a' + 4));
+
+ System.out.println("a" + 1);
+
+ // integer will be converted to the integer that will call tostring()
+
+ // System.out.println(new Integer(0) + new ArrayList());
+ // for this , you will be seeing an error because (+) operator in java is only defined for primitive data types & if one of these value is a strinng
+
+ // to correct upper case error
+ System.out.println(new Integer(0) + " " + new ArrayList());
+ }
+}
diff --git a/10_String/StringIntro.java b/10_String/StringIntro.java
new file mode 100644
index 0000000..732138a
--- /dev/null
+++ b/10_String/StringIntro.java
@@ -0,0 +1,76 @@
+
+public class StringIntro {
+
+ public static void main(String[] args) {
+ int str[] = {2, 3, 4, 5, 19}
+ int a = 10;
+ String name = "LAksh Yadav";
+ System.out.println(name);
+ String b = "ALksh";
+ b = "Yadav"
+ System.out.println(b);
+ }
+}
+
+// // โ 1. Everything that starts with a capital letter is usually a Class in Java
+// // Examples: String, Scanner, ArrayList, Integer, etc.
+
+
+// // โ 2. Syntax for creating a String object
+// String name = "Kunal"; // Datatype referenceVariable = object;
+
+
+// // โ 3. Important Concepts in String Manipulation:
+// // a. String Pool
+// // b. Immutability
+// // c. == vs .equals()
+
+
+// // โ a. String Pool
+// // The String pool is a special area in heap memory where Java stores string literals.
+// // If two strings have the same value, they will point to the same object in the pool.
+
+// String a = "Kunal";
+// String b = "Kunal";
+
+// System.out.println(a == b); // true โ both point to the same object in the string pool
+
+
+// // BUT if you use 'new String()', a new object is created even if the value is the same:
+
+// String c = new String("Kunal");
+
+// System.out.println(a == c); // false โ different memory location
+// System.out.println(a.equals(c)); // true โ same value
+
+
+// // โ b. Immutability
+// // Strings in Java are immutable. You can't change the original string object.
+// // Any operation that modifies a string actually creates a **new** string object.
+
+// String str = "Hello";
+// str = str + " World";
+
+// System.out.println(str); // Output: Hello World
+
+// // Original "Hello" string still exists in memory (if not garbage collected).
+
+
+// // โ c. == vs .equals()
+// // == checks if two references point to the same object in memory.
+// // .equals() checks if two objects have the same value/content.
+
+// String x = "Java";
+// String y = "Java";
+// String z = new String("Java");
+
+// System.out.println(x == y); // true โ both from string pool
+// System.out.println(x == z); // false โ z is a new object
+// System.out.println(x.equals(z)); // true โ same content
+
+
+// // โ TL;DR (Cheat Sheet)
+// // - Use .equals() to compare string values.
+// // - Avoid using 'new String()' unless necessary.
+// // - Strings are immutable, use StringBuilder for heavy string manipulation.
+// // - String pool saves memory by avoiding duplicate literals.
diff --git a/10_String/StringSeven.class b/10_String/StringSeven.class
new file mode 100644
index 0000000..c830c83
Binary files /dev/null and b/10_String/StringSeven.class differ
diff --git a/10_String/StringSeven.java b/10_String/StringSeven.java
new file mode 100644
index 0000000..462f7f3
--- /dev/null
+++ b/10_String/StringSeven.java
@@ -0,0 +1,26 @@
+import java.util.Arrays;
+
+public class StringSeven {
+
+ public static void main(String[] args) {
+ // string method 1 in JAVA
+ String name = "John Doe";
+ System.out.println(Arrays.toString(name.toCharArray()));
+
+ // string method 2 in JAVA
+ System.out.println("Length: " + name.length());
+
+ // string method 3 in JAVA
+ System.out.println("Uppercase: " + name.toUpperCase());
+ System.out.println("Lowercase: " + name.toLowerCase());
+
+ // string method 4 in JAVA
+ System.out.println("Index of o: " + name.indexOf('o'));
+
+ // string method 5 in JAVA
+ System.out.println("Replace 'o' with 'a': " + name.replace('o', 'a'));
+
+ // string method 6 in JAVA
+ System.out.println("Substring(1, 3): " + name.substring(1, 3));
+ }
+}
diff --git a/10_String/StringSix.class b/10_String/StringSix.class
new file mode 100644
index 0000000..0e0ed27
Binary files /dev/null and b/10_String/StringSix.class differ
diff --git a/10_String/StringSix.java b/10_String/StringSix.java
new file mode 100644
index 0000000..edcf0b5
--- /dev/null
+++ b/10_String/StringSix.java
@@ -0,0 +1,14 @@
+public class StringSix {
+ public static void main(String[] args) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < 26; i++) { + char ch = (char) ('a' + i); + builder.append(ch); + System.out.println(builder.toString()); + builder.deleteCharAt(0); + System.out.println(builder); + } + } +} + +// try to explore more builder functions diff --git a/10_String/StringTest.class b/10_String/StringTest.class new file mode 100644 index 0000000..7663106 Binary files /dev/null and b/10_String/StringTest.class differ diff --git a/10_String/StringThree.java b/10_String/StringThree.java new file mode 100644 index 0000000..fc884ce --- /dev/null +++ b/10_String/StringThree.java @@ -0,0 +1,9 @@ +public class StringThree { + public static void main(String[] args) { + //printing decimal point values + + float a = 45.345f; + + System.out.println("formated number is % .2f" \n, a); + } +} diff --git a/10_String/Stringtwo.class b/10_String/Stringtwo.class new file mode 100644 index 0000000..58b710f Binary files /dev/null and b/10_String/Stringtwo.class differ diff --git a/10_String/Stringtwo.java b/10_String/Stringtwo.java new file mode 100644 index 0000000..3b32549 --- /dev/null +++ b/10_String/Stringtwo.java @@ -0,0 +1,19 @@ +import java.util.Arrays; + +public class Stringtwo { + public static void main(String[] args) { + System.out.println("56"); + System.err.println("Kunal"); + System.out.println(Arrays.toString(new int[] {1, 2, 3, 4})); + } +} + + + +// For executing every command in println(), it is calling the return Integer.toString() method. + +// If it is a null object, it will print null, otherwise it prints toString(). + +// Every time we println() or pass any object into it, it calls the .value โ then with one "cmd" operator checks whether the object is null or not โ then + โ null or obj.toString() + +// With Arrays.toString() โ you're overriding default toString() in Java. \ No newline at end of file diff --git a/11_OOPs/11_OOPs.iml b/11_OOPs/11_OOPs.iml new file mode 100644 index 0000000..6a8209d --- /dev/null +++ b/11_OOPs/11_OOPs.iml @@ -0,0 +1,11 @@ +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/11_OOPs/OOPs1/ClassFour$A.class b/11_OOPs/OOPs1/ClassFour$A.class
new file mode 100644
index 0000000..a446e49
Binary files /dev/null and b/11_OOPs/OOPs1/ClassFour$A.class differ
diff --git a/11_OOPs/OOPs1/ClassFour.class b/11_OOPs/OOPs1/ClassFour.class
new file mode 100644
index 0000000..7b8cb37
Binary files /dev/null and b/11_OOPs/OOPs1/ClassFour.class differ
diff --git a/11_OOPs/OOPs1/ClassFour.java b/11_OOPs/OOPs1/ClassFour.java
new file mode 100644
index 0000000..2034e08
--- /dev/null
+++ b/11_OOPs/OOPs1/ClassFour.java
@@ -0,0 +1,44 @@
+// public class ClassFour {
+// public static void main(String[] args) {
+// // wrapper class examples
+// int a = 10;
+// int b = 20;
+// Integer c = 30;
+// Integer d = 40;
+
+// // the above one is a primitive example and it will not give you much options.
+// // for the Integer now gives you an object which gives lots of properties with integers.
+// // if I try to swap the primitive values, they won't swap; only pass by reference values swap with each other.
+
+// swap(a, b);
+// swap2(c, d);
+
+// System.out.println(a + " " + b);
+
+// final A John = new ClassFour.A("John Doe");
+// John.name = "other name";
+// }
+
+// static void swap(int a, int b) {
+// int temp = a;
+// a = b;
+// b = temp;
+// }
+
+// static void swap2(Integer c, Integer d) {
+// int temp = c;
+// c = d;
+// d = temp;
+// // In this case also they won't swap due to Java's pass-by-value semantics.
+// }
+
+// static class A {
+// final int num = 10;
+// String name;
+// public A(String name) {
+// this.name = name;
+// }
+// }
+// }
+
+// // the case with the finalis your cannot change the value, when its primitive data types and foer the reference one you can change the datatype.
diff --git a/11_OOPs/OOPs1/ClassThree.java b/11_OOPs/OOPs1/ClassThree.java
new file mode 100644
index 0000000..c0bfa91
--- /dev/null
+++ b/11_OOPs/OOPs1/ClassThree.java
@@ -0,0 +1,20 @@
+
+
+// public class ClassThree {
+// public static void main(String[] args) {
+// //> Now, creating two object and pointing to each other is same as like refernce variable pointing towards the same object behind the scences.
+
+// //Student one = new Student();
+// //Student two = one;
+
+// // Assiging values using 'one';
+// // one.name = "John doe";
+// // one.age = 20;
+// // one.marks = 85.5f;
+
+// // printing values using two,
+// // System.out.println("two.name:" + two.name);
+// // System.out.println("two.age:" + two.age);
+// // System.out.println("two.marks:" + two.marks);
+// }
+// }
diff --git a/11_OOPs/OOPs1/ClassTwo.java b/11_OOPs/OOPs1/ClassTwo.java
new file mode 100644
index 0000000..f11cb2d
--- /dev/null
+++ b/11_OOPs/OOPs1/ClassTwo.java
@@ -0,0 +1,42 @@
+// public class classTwo {
+// public static void main(String[] args) {
+// // constructor comes into play
+// // constructor - a constructor basically definers what happens when you object is created.
+// // a contructor is an special type of function in class, which binds argumenst with the objects.
+// // for ex- students johm = new student("Alice", 20);
+// // we need on word to access every object. That word will be new approach "this keyword".
+
+
+// // old approach
+// // students s1() {
+// // s1.name = "Rahul";
+// // s1.age = 20;
+// // s1.marks = 88.804 }
+
+// // new approach
+// // students s1() {
+// // this.name = "Rahul";
+// // this.age = 20;
+// // thsi.marks = 88.804 }
+
+// // for the every new object created the 'this' keyword, takes name, age, marks.
+
+// // student s1 = new student("John", 34, 88.45f);
+// // student s2 = new student("Hercules", 34, 88.45f);
+
+// //System.out.println(s1.name + " " + s1.age + " " + s1.marks);
+// //System.out.println(s2.name + " " + s2.age + " " + s2.marks);
+
+// }
+// }
+
+// // class student {
+// // string name;
+// // int age;
+// // float marks;
+// //student(string name, int age, float marks) {
+// //this.name = name;
+// // this.age = age;
+// // this.marks = marks;
+// //}
+// //}
diff --git a/11_OOPs/OOPs1/Main.java b/11_OOPs/OOPs1/Main.java
new file mode 100644
index 0000000..7d0923d
--- /dev/null
+++ b/11_OOPs/OOPs1/Main.java
@@ -0,0 +1,41 @@
+// // Abstraction + Encapsulation
+// class Animal {
+// private String name; // Encapsulation: private + getters/setters
+
+// public Animal(String name) {
+// this.name = name;
+// }
+
+// public String getName() {
+// return name;
+// }
+
+// public void speak() { // Polymorphism: overridden in subclass
+// System.out.println("Animal is making a sound...");
+// }
+// }
+
+// // Inheritance
+// class Dog extends Animal {
+// public Dog(String name) {
+// super(name); // Calling parent constructor
+// }
+
+// // Polymorphism: method overriding
+// @Override
+// public void speak() {
+// System.out.println(getName() + " says: Woof Woof!");
+// }
+// }
+
+// // Main class to test OOP concepts
+// public class Main {
+// public static void main(String[] args) {
+// Animal myAnimal = new Animal("GenericAnimal");
+// Dog myDog = new Dog("Bruno");
+
+// myAnimal.speak(); // Output: Animal is making a sound...
+// myDog.speak(); // Output: Bruno says: Woof Woof!
+// // Output: Bruno says: Woof Woof!
+// }
+// }
diff --git a/11_OOPs/OOPs1/OOPsConceptes.java b/11_OOPs/OOPs1/OOPsConceptes.java
new file mode 100644
index 0000000..ae97fd8
--- /dev/null
+++ b/11_OOPs/OOPs1/OOPsConceptes.java
@@ -0,0 +1,23 @@
+// OOPS โ abs; inher; poly; encap -
+
+// Class, Objects
+
+// this, super, final key word
+
+// Collections framework
+
+// custom ArrayList
+
+// Exception Handling โ throw, try, catch, finally
+
+// lambda expression
+
+// Object cloning
+
+// abstract classes, interfaces
+
+// packages
+
+// public vs private
+
+// interfaces
\ No newline at end of file
diff --git a/11_OOPs/OOPs1/One.java b/11_OOPs/OOPs1/One.java
new file mode 100644
index 0000000..01c1cf9
--- /dev/null
+++ b/11_OOPs/OOPs1/One.java
@@ -0,0 +1,71 @@
+
+// public class One {
+
+// public static void main(String[] args) {
+// // store 5 roll no.
+// int[] numbers = new int[5];
+
+// // store 5 names
+// String[] names = new String[5];
+
+// // now i want a container to store data - names, rollno., marks etc..
+// // Your apprache:
+// //> Int [] rollno = new int [5];
+// //> String [] Studentname = new string [5];
+// //> Float [] marks = new float [5]
+// // // you have created 3 different objects for 3 different entities, which is not feasible
+// // Suppose ,what if i want a data structure in which every single element stores above
+// //this is where classes and objects came into java.
+// // initializing a class:
+// // Statement []students=new Statement[];
+// // class Student{
+// // int [] roll no.=new int[5];
+// // String StudentName=new String[];
+// // float[]marks=new float[5];
+// }
+// }
+
+
+// // Classes are just like a template, for ex - car is an template and from that many companies have created so many brands and cars.
+// // For ex - car can have - seats, engine, prive, this ids an general template every car has.
+// // Like - Maruti, ferrari, etc...abstract
+
+// // Car template does not exist physically, through you can find cars and models. Tewmplate are like rule of something car brands has to follow while making a car
+
+// // -> a class is an template ofg an object.
+// // -> an object is an instance of an class.
+
+// // classes are "logical construction", Objects are -> "Physical Reality"
+
+// // For ex - i have created 3 objects of the class
+// // -> 3 refence variables and with the (.) operatot, they are linked with the instance variable of the class template
+
+
+// // You will get null whentry to print an empty object.
+// // System.out.println(students);
+
+// // to see something instead of null, we use "new " keyword which dynamically allocates memory at runtime and returns a refrence variable.
+
+// // Student student1 = new students();
+
+// // Student student1 ==> Happening at compile time
+// // -> code is exceuting
+// // -> errors are shown
+// // -> Source code -> byte code
+// // Now, when i do, S1. name, S1. rollno.
+
+// // new students(); ==> Happening at run time
+// // -> after verification java running your code and memory is being allocated
+// // It checks wheather i have assigned a value and if not, it prints the default value instead.
+
+
+// // Student student1 ==> Happening at compile time
+// // -> code is exceuting
+// // -> errors are shown
+// // -> Source code -> byte code
+// // Now, when i do, S1. name, S1. rollno.
+
+// // new students(); ==> Happening at run time
+// // -> after verification java running your code and memory is being allocated
+// // It checks wheather i have assigned a value and if not, it prints the default value instead.
+
diff --git a/11_OOPs/OOPs1/classFive.java b/11_OOPs/OOPs1/classFive.java
new file mode 100644
index 0000000..acbad99
--- /dev/null
+++ b/11_OOPs/OOPs1/classFive.java
@@ -0,0 +1,21 @@
+// static class Box {
+// int value;
+
+// Box(int value) {
+// this.value = value;
+// }
+// }
+
+// static void swapBoxes(Box x, Box y) {
+// int temp = x.value;
+// x.value = y.value;
+// y.value = temp;
+// }
+
+// public static void main(String[] args) {
+// Box a = new Box(10);
+// Box b = new Box(20);
+
+// swapBoxes(a, b);
+// System.out.println("a.value = " + a.value + ", b.value = " + b.value);
+// }
diff --git a/11_OOPs/OOPs1/new.java b/11_OOPs/OOPs1/new.java
new file mode 100644
index 0000000..011d856
--- /dev/null
+++ b/11_OOPs/OOPs1/new.java
@@ -0,0 +1,75 @@
+// Abstract Class (Abstraction)
+abstract class BankAccount {
+ private String accountHolder;
+ private double balance;
+
+ public BankAccount(String accountHolder, double initialBalance) {
+ this.accountHolder = accountHolder;
+ this.balance = initialBalance;
+ }
+
+ // Encapsulation: private variables with public access methods
+ public String getAccountHolder() {
+ return accountHolder;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void deposit(double amount) {
+ balance += amount;
+ }
+
+ public void withdraw(double amount) {
+ if (balance>= amount) {
+ balance -= amount;
+ } else {
+ System.out.println("โ Insufficient funds!");
+ }
+ }
+
+ // Abstract Method (must be implemented in subclass)
+ public abstract void showAccountType();
+}
+
+// Inheritance + Polymorphism
+class SavingsAccount extends BankAccount {
+ public SavingsAccount(String accountHolder, double initialBalance) {
+ super(accountHolder, initialBalance);
+ }
+
+ @Override
+ public void showAccountType() {
+ System.out.println("๐ฆ This is a Savings Account.");
+ }
+}
+
+// Another Subclass for variety
+class CurrentAccount extends BankAccount {
+ public CurrentAccount(String accountHolder, double initialBalance) {
+ super(accountHolder, initialBalance);
+ }
+
+ @Override
+ public void showAccountType() {
+ System.out.println("๐ผ This is a Current Account.");
+ }
+}
+
+// Main Class to Run It
+public class Main {
+ public static void main(String[] args) {
+ BankAccount acc1 = new SavingsAccount("Piyush", 1000);
+ BankAccount acc2 = new CurrentAccount("Soni", 2000);
+
+ acc1.deposit(500);
+ acc2.withdraw(1500);
+
+ System.out.println(acc1.getAccountHolder() + "'s balance: โน" + acc1.getBalance());
+ acc1.showAccountType();
+
+ System.out.println(acc2.getAccountHolder() + "'s balance: โน" + acc2.getBalance());
+ acc2.showAccountType();
+ }
+}
diff --git a/11_OOPs/OOPs2/oops/oops2/Greeting.java b/11_OOPs/OOPs2/oops/oops2/Greeting.java
new file mode 100644
index 0000000..0b7d160
--- /dev/null
+++ b/11_OOPs/OOPs2/oops/oops2/Greeting.java
@@ -0,0 +1,12 @@
+// package oops.oops2;
+
+// public class Greeting {
+// public static void main(String[] args) {
+// System.out.println("Hello from Greeting class main()");
+// Message.message();
+// }
+
+// public static void messageGreeting() {
+// System.out.println("Greetings from Greeting class!");
+// }
+// }
diff --git a/11_OOPs/OOPs2/oops/oops2/Message.java b/11_OOPs/OOPs2/oops/oops2/Message.java
new file mode 100644
index 0000000..78f187c
--- /dev/null
+++ b/11_OOPs/OOPs2/oops/oops2/Message.java
@@ -0,0 +1,13 @@
+// package oops.oops2;
+
+// public class Message {
+// public static void message() {
+// System.out.println("This is the message box");
+// }
+
+// public static void main(String[] args) {
+// System.out.println("Inside Message class main()");
+// Greeting.messageGreeting();
+// }
+// }
+
\ No newline at end of file
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticExample/Main.java b/11_OOPs/OOPs2/oops/oops2/StaticExample/Main.java
new file mode 100644
index 0000000..e69de29
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticExample/User.class b/11_OOPs/OOPs2/oops/oops2/StaticExample/User.class
new file mode 100644
index 0000000..b59fa26
Binary files /dev/null and b/11_OOPs/OOPs2/oops/oops2/StaticExample/User.class differ
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticExample/User.java b/11_OOPs/OOPs2/oops/oops2/StaticExample/User.java
new file mode 100644
index 0000000..8ced42c
--- /dev/null
+++ b/11_OOPs/OOPs2/oops/oops2/StaticExample/User.java
@@ -0,0 +1,29 @@
+// public class User {
+// int age;
+// String name;
+// int salary;
+// boolean married;
+// static long population;
+
+// public User(int age, String name, int salary, boolean married) {
+// this.age = age;
+// this.name = name;
+// this.salary = salary;
+// this.married = married;
+// User.population += 1;
+
+// }
+
+// public void displayInfo() {
+// System.out.println(name + " | Age: " + age + " | Salary: " + salary + " | Married: " + married);
+// }
+// }
+
+
+// // In this user class, there's no need for a main() method unless you're writing a test or trying it independently.
+// // Import statments are also unessary when using classes in the same packeage.
+// // It is because java automatically recognize then within the package heiriacy.
+// // Those properties which are independent from the objects from which they are created are called -- stataic variables.
+// // Population is common to both the objects of the parent class. but, there's a doubt?
+// // If "static" is independent of the object, then why used this keyword??
+// // = It should be used with the class insted.
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree$Test.class b/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree$Test.class
new file mode 100644
index 0000000..6154425
Binary files /dev/null and b/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree$Test.class differ
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree.class b/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree.class
new file mode 100644
index 0000000..28dfab6
Binary files /dev/null and b/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree.class differ
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree.java b/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree.java
new file mode 100644
index 0000000..d083c05
--- /dev/null
+++ b/11_OOPs/OOPs2/oops/oops2/StaticThree/staticThree.java
@@ -0,0 +1,36 @@
+// public class staticThree {
+// static void showMessage() {
+// System.out.println("Static method called from Test class!");
+// }
+
+// // Static nested class
+// static class Test {
+// String name;
+
+// public Test(String name) {
+// this.name = name;
+// }
+
+// public void printName() {
+// System.out.println("Name: " + name);
+// }
+// }
+
+
+
+// public static void main(String[] args) {
+// // Creating objects of static nested class using outer class name
+// StaticThree.Test a = new StaticThree.Test("Laksh");
+// StaticThree.Test b = new StaticThree.Test("Parv");
+
+// // Call method to display names
+// a.printName();
+// b.printName();
+// // calling the static method directly
+// StaticThree.showMessage();
+// }
+// }
+
+// // Outside classes cannot be static
+// // Any inside/ nested classes can be static
+// // creating constructor here
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticTwo/staticTwo.class b/11_OOPs/OOPs2/oops/oops2/StaticTwo/staticTwo.class
new file mode 100644
index 0000000..847a4f4
Binary files /dev/null and b/11_OOPs/OOPs2/oops/oops2/StaticTwo/staticTwo.class differ
diff --git a/11_OOPs/OOPs2/oops/oops2/StaticTwo/staticTwo.java b/11_OOPs/OOPs2/oops/oops2/StaticTwo/staticTwo.java
new file mode 100644
index 0000000..f5f2e6f
--- /dev/null
+++ b/11_OOPs/OOPs2/oops/oops2/StaticTwo/staticTwo.java
@@ -0,0 +1,18 @@
+// public class staticTwo {
+// static int a = 4;
+// static int b;
+// // this is how, we initialize static variables.
+
+// static {
+// System.out.println("I am the static block");
+// // this block will only reuns when the 1st object is created or when the class is loaded for the 1st time.
+// b = a * 5;
+// }
+// public static void main (String [] args) {
+// staticTwo obj = new staticTwo();
+// System.out.println(staticTwo.a + " " + staticTwo.b);
+// staticTwo.b += 3;
+// staticTwo obj2 = new staticTwo();
+// System.out.println(staticTwo.a + " " + staticTwo.b);
+// }
+// }
diff --git a/11_OOPs/OOPs3/Intro/Inheritanceone.class b/11_OOPs/OOPs3/Intro/Inheritanceone.class
new file mode 100644
index 0000000..ac0360b
Binary files /dev/null and b/11_OOPs/OOPs3/Intro/Inheritanceone.class differ
diff --git a/11_OOPs/OOPs3/Intro/Inheritanceone.java b/11_OOPs/OOPs3/Intro/Inheritanceone.java
new file mode 100644
index 0000000..8b010d4
--- /dev/null
+++ b/11_OOPs/OOPs3/Intro/Inheritanceone.java
@@ -0,0 +1,50 @@
+public class Inheritanceone {
+ double l;
+ double w;
+ double h;
+
+ Inheritanceone() {
+ this.l = -1;
+ this.w = -1;
+ this.h = -1;
+ // Default Constructor
+ }
+
+ Inheritanceone(double side) {
+ this.l = side;
+ this.w = side;
+ this.h = side;
+ // Parameterized Constructor
+ }
+
+ public Inheritanceone(double l, double w, double h) {
+ this.l = l;
+ this.w = w;
+ this.h = h;
+ // Passing all three arguments
+ }
+
+ Inheritanceone(Inheritanceone old) {
+ this.l = old.l;
+ this.w = old.w;
+ this.h = old.h;
+ // Copy Constructor
+ }
+
+ public void Information() {
+ System.out.println("Running the Box");
+ }
+
+}
+
+ // Inheritance, simply defines, inheriting or deriving properties from the parent class by the child class.
+ // Any class derived from the base class is the child class.
+ // Child class inherits properties(variables, methods etc.) from the baseclass.
+ // 'extends' keyword is the bridge b/w base class and the child class
+ // Now, the child class has all the properties of the base class + properties of thier own.
+ // When defining the constructor, you also need to initialize parent class variable also.
+
+
+
+
+
diff --git a/11_OOPs/OOPs3/Intro/Inheritancetwo.class b/11_OOPs/OOPs3/Intro/Inheritancetwo.class
new file mode 100644
index 0000000..33a7183
Binary files /dev/null and b/11_OOPs/OOPs3/Intro/Inheritancetwo.class differ
diff --git a/11_OOPs/OOPs3/Intro/Inheritancetwo.java b/11_OOPs/OOPs3/Intro/Inheritancetwo.java
new file mode 100644
index 0000000..56a9010
--- /dev/null
+++ b/11_OOPs/OOPs3/Intro/Inheritancetwo.java
@@ -0,0 +1,14 @@
+public class Inheritancetwo {
+ public static void main(String[] args) {
+ Inheritanceone box = new Inheritanceone();
+ System.out.println(box.l + " " + box.w + " " + box.h);
+
+ Inheritanceone box2 = new Inheritanceone(4);
+ System.out.println(box2.l + " " + box2.w + " " + box2.h);
+
+ Inheritanceone box3 = new Inheritanceone(4.5, 5.5, 6.5);
+ System.out.println(box3.l + " " + box3.w + " " + box3.h );
+
+
+ }
+}
diff --git a/11_OOPs/OOPs3/OOPs3.iml b/11_OOPs/OOPs3/OOPs3.iml
new file mode 100644
index 0000000..cc54297
--- /dev/null
+++ b/11_OOPs/OOPs3/OOPs3.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/11_OOPs/OOPs3/PublicPrivate/Animal.java b/11_OOPs/OOPs3/PublicPrivate/Animal.java
new file mode 100644
index 0000000..0ed62b5
--- /dev/null
+++ b/11_OOPs/OOPs3/PublicPrivate/Animal.java
@@ -0,0 +1,15 @@
+// package 11_OOPs.OOPs3.PublicPrivate;
+
+// public class Animal {
+// private String Name = "Genric Animal";// Private: not accessible outside this class
+// public int Age = 5;
+// public void displayAge() {
+// System.out.println("Age" + Age);// Public: accesible anywhere
+// }
+// private void SecretMethod() {
+// System.out.println("This is a private method in animal");
+// }
+// public void PrivateMethod() {
+// SecretMethod();//you can call a function from a private
+// }
+// }
diff --git a/11_OOPs/OOPs3/PublicPrivate/Dog.java b/11_OOPs/OOPs3/PublicPrivate/Dog.java
new file mode 100644
index 0000000..5d4d8e5
--- /dev/null
+++ b/11_OOPs/OOPs3/PublicPrivate/Dog.java
@@ -0,0 +1,16 @@
+// package 11_OOPs.OOPs3.PublicPrivate;
+
+// public class Dog extends Animal {
+
+// public void bark() {
+// // Using getter to access private Name from Animal
+// // System.out.println("Name: " + Name);
+// System.out.println("Dog Barks");
+// System.out.println("Age from Animal: " + age);
+// }
+
+// public void testPrivateAccess() {
+// // SecretMethod(); โ Not allowed, it's private
+// PrivateMethod() // โ This is allowed
+// }
+// }
diff --git a/11_OOPs/OOPs3/PublicPrivate/Main.java b/11_OOPs/OOPs3/PublicPrivate/Main.java
new file mode 100644
index 0000000..666fe6b
--- /dev/null
+++ b/11_OOPs/OOPs3/PublicPrivate/Main.java
@@ -0,0 +1,14 @@
+// package 11_OOPs.OOPs3.PublicPrivate;
+
+// public class Main {
+// public static void main(String[] args) {
+// Dog d = new Dog();
+
+// d.bank();
+// d.displayAge(); // accessing public method of parent
+// d.testPrivateAccess(); // works indireclty calls private method
+
+// System.out.println("Age: " + d.age);
+// System.out.println("Name:" + d.name); // error private
+// }
+// }
diff --git a/11_OOPs/OOPs3/ThisSuperKeyword/Main.java b/11_OOPs/OOPs3/ThisSuperKeyword/Main.java
new file mode 100644
index 0000000..dac6fe0
--- /dev/null
+++ b/11_OOPs/OOPs3/ThisSuperKeyword/Main.java
@@ -0,0 +1,44 @@
+// class Animal {
+// String type = "Animal";
+
+// Animal(){
+// System.out.println("Animal Constructor called");
+// }
+// void sound(){
+// System.out.println("Animal makes sound");
+// }
+
+// };
+
+// //Now creating a child class of Animal -Dog
+// class Dog extends Animal{
+// String type = "Dog";
+
+
+// Dog(){
+// //super is eleigible because, Dog is a child class of the parent Animal
+// super();
+// System.out.println("Dog contructor called");
+// }
+// void showType(){
+// // iska mtlb, dog mei jo ho rha hai uske dekhne ke liye - this keyword use hoga
+// // dog ke parent mei jo ho rha hai usko dekhne ke liye super use hoga
+// System.out.println("Type in Child :"+ this.type);
+// System.out.println("Type in Parent :"+ super.type);
+// }
+
+// void sound(){
+// super.sound(); // called the parent class sound method
+// System.out.println("Dog barks");
+// }
+
+
+// };
+
+// public class Main {
+// public static void main(String[] args) {
+// Dog dog = new Dog();
+// dog.showType();
+// dog.sound();
+// }
+// }
\ No newline at end of file
diff --git a/11_OOPs/OOPs3/ThisSuperKeyword/SuperDemoThree.java b/11_OOPs/OOPs3/ThisSuperKeyword/SuperDemoThree.java
new file mode 100644
index 0000000..e482075
--- /dev/null
+++ b/11_OOPs/OOPs3/ThisSuperKeyword/SuperDemoThree.java
@@ -0,0 +1,38 @@
+// class Payment{
+// double amount;
+// //making the constructor for the Payment class
+// Payment(double amount){
+// this.amount = amount;
+// System.out.println("Payment created for the amount :"+ amount);
+// }
+// //creatinf the pay method
+// void pay(){
+// System.out.println("Processing generic payment...");
+// }
+// };
+
+// //Creating a child class now
+// class CrediCardPayment extends Payment{
+// String cardNumber;
+
+// //creating the constructor for this
+// CrediCardPayment(double amount, String cardNumber){
+// super(amount);
+// this.cardNumber = cardNumber;
+// }
+// // overriding the pay method
+// @Override
+// void pay(){
+// super.pay();
+// System.out.println("Processing credit card payment with card :"+ cardNumber);
+// }
+// }
+
+// public class SuperDemoThree{
+// public static void main(String[] args) {
+// CrediCardPayment ccp = new CrediCardPayment(1000,"1234-5678-9876-5432");
+// ccp.pay();
+// Payment payone = new Payment(500);
+// payone.pay();
+// }
+// }
\ No newline at end of file
diff --git a/11_OOPs/OOPs3/ThisSuperKeyword/SuperDemoTwo.java b/11_OOPs/OOPs3/ThisSuperKeyword/SuperDemoTwo.java
new file mode 100644
index 0000000..884caae
--- /dev/null
+++ b/11_OOPs/OOPs3/ThisSuperKeyword/SuperDemoTwo.java
@@ -0,0 +1,29 @@
+class Employee{
+ String name;
+ double salary;
+ int age;
+ char alpha;
+
+ //creating the constructor here
+ Employee(String name,double salary, int age, char alpha){
+ this.name = name;
+ this.salary = salary;
+ this.age = age;
+ this.alpha = alpha;
+
+ }
+
+ void showinfo(){
+ System.out.println("Employee:"+ this.name);
+ System.out.println("Salary :"+ this.salary);
+ System.out.println("Age :"+ this.age);
+ System.out.println("Alphbet :"+ this.alpha);
+ }
+};
+
+public class SuperDemoTwo{
+ public static void main(String[] args) {
+ Employee emp = new Employee("John",50000 ,23,'A');
+ emp.showinfo();
+ }
+}
\ No newline at end of file
diff --git a/11_OOPs/OOPs4/Modifiers/Main.java b/11_OOPs/OOPs4/Modifiers/Main.java
new file mode 100644
index 0000000..792403f
--- /dev/null
+++ b/11_OOPs/OOPs4/Modifiers/Main.java
@@ -0,0 +1,25 @@
+package OOPS.oops6.pACKAEGES.modifiers;
+
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.Base;
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.SamePackageChild;
+import OOPS.oops6.pACKAEGES.modifiers.packageTwo.DifferentPackageChild;
+
+public class Main {
+ public static void main(String[] args) {
+ Base base = new Base();
+ base.showAccess();
+ System.out.println("----------");
+
+ SamePackageChild spc = new SamePackageChild();
+ spc.accessFromSamePackageChild();
+ System.out.println("----------");
+
+ DifferentPackageChild dpc = new DifferentPackageChild();
+ dpc.accessFromDifferentPackageChild();
+ System.out.println("----------");
+
+ OutsideWorld world = new OutsideWorld();
+ world.accessFromOutsideWorld();
+ }
+}
+
diff --git a/11_OOPs/OOPs4/Modifiers/OutsideWorld.java b/11_OOPs/OOPs4/Modifiers/OutsideWorld.java
new file mode 100644
index 0000000..73cb149
--- /dev/null
+++ b/11_OOPs/OOPs4/Modifiers/OutsideWorld.java
@@ -0,0 +1,14 @@
+package OOPS.oops6.pACKAEGES.modifiers;
+
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.Base;
+
+public class OutsideWorld {
+ public void accessFromOutsideWorld() {
+ Base obj = new Base();
+ System.out.println("OutsideWorld access:");
+ System.out.println("public: " + obj.publicVar);
+ // System.out.println("protected: " + obj.protectedVar); // โ
+ // System.out.println("default: " + obj.defaultVar); // โ
+ // System.out.println("private: " + obj.privateVar); // โ
+ }
+ };
\ No newline at end of file
diff --git a/11_OOPs/OOPs4/Modifiers/packageOne/Base.java b/11_OOPs/OOPs4/Modifiers/packageOne/Base.java
new file mode 100644
index 0000000..3f6e34e
--- /dev/null
+++ b/11_OOPs/OOPs4/Modifiers/packageOne/Base.java
@@ -0,0 +1,21 @@
+package OOPS.oops6.pACKAEGES.modifiers.packageOne;
+
+
+
+public class Base {
+ public int publicVar = 1;
+ protected int protectedVar = 2;
+ int defaultVar = 3; // package-private
+ private int privateVar = 4;
+
+ public void showAccess() {
+ System.out.println("Base class access:");
+ System.out.println("public: " + publicVar);
+ System.out.println("protected: " + protectedVar);
+ System.out.println("default: " + defaultVar);
+ System.out.println("private: " + privateVar);
+ }
+}
+
+
+
diff --git a/11_OOPs/OOPs4/Modifiers/packageOne/SamePackageChild.java b/11_OOPs/OOPs4/Modifiers/packageOne/SamePackageChild.java
new file mode 100644
index 0000000..b443684
--- /dev/null
+++ b/11_OOPs/OOPs4/Modifiers/packageOne/SamePackageChild.java
@@ -0,0 +1,12 @@
+package OOPS.oops6.pACKAEGES.modifiers.packageOne;
+
+public class SamePackageChild extends Base {
+ public void accessFromSamePackageChild() {
+ System.out.println("SamePackageChild access:");
+ System.out.println("public: " + publicVar);
+ System.out.println("protected: " + protectedVar);
+ System.out.println("default: " + defaultVar); // โ allowed (same package)
+ // System.out.println("private: " + privateVar); // โ not allowed
+ }
+}
+
diff --git a/11_OOPs/OOPs4/Modifiers/packageTwo/DifferentPackageChild.java b/11_OOPs/OOPs4/Modifiers/packageTwo/DifferentPackageChild.java
new file mode 100644
index 0000000..f7e50ca
--- /dev/null
+++ b/11_OOPs/OOPs4/Modifiers/packageTwo/DifferentPackageChild.java
@@ -0,0 +1,13 @@
+package OOPS.oops6.pACKAEGES.modifiers.packageTwo;
+
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.Base;
+
+public class DifferentPackageChild extends Base {
+ public void accessFromDifferentPackageChild() {
+ System.out.println("DifferentPackageChild access:");
+ System.out.println("public: " + publicVar);
+ System.out.println("protected: " + protectedVar); // โ inherited access
+ // System.out.println("default: " + defaultVar); // โ not allowed
+ // System.out.println("private: " + privateVar); // โ not allowed
+ }
+}
diff --git a/11_OOPs/OwnPractise/Main.java b/11_OOPs/OwnPractise/Main.java
new file mode 100644
index 0000000..7349707
--- /dev/null
+++ b/11_OOPs/OwnPractise/Main.java
@@ -0,0 +1,76 @@
+// // Interface (Abstraction)
+// interface Vehicle {
+// void start();
+// void stop();
+// }
+
+// // Base Class (Encapsulation with private fields)
+// class Car implements Vehicle {
+// private String brand;
+// private int year;
+
+// // Constructor
+// public Car(String brand, int year) {
+// this.brand = brand;
+// this.year = year;
+// }
+
+// // Getters and Setters (Encapsulation)
+// public String getBrand() {
+// return brand;
+// }
+
+// public int getYear() {
+// return year;
+// }
+
+// public void start() {
+// System.out.println(brand + " is starting...");
+// }
+
+// public void stop() {
+// System.out.println(brand + " has stopped.");
+// }
+
+// public void displayDetails() {
+// System.out.println("Brand: " + brand + ", Year: " + year);
+// }
+// }
+
+// // Derived Class (Inheritance)
+// class ElectricCar extends Car {
+// private int batteryLife;
+
+// public ElectricCar(String brand, int year, int batteryLife) {
+// super(brand, year); // calling parent constructor
+// this.batteryLife = batteryLife;
+// }
+
+// // Overriding Method (Polymorphism)
+// @Override
+// public void start() {
+// System.out.println(getBrand() + " (Electric) is starting silently...");
+// }
+
+// public void displayBattery() {
+// System.out.println("Battery Life: " + batteryLife + "%");
+// }
+// }
+
+// // Main Class
+// public class Main {
+// public static void main(String[] args) {
+// Car myCar = new Car("Toyota", 2020);
+// myCar.start();
+// myCar.displayDetails();
+// myCar.stop();
+
+// System.out.println();
+
+// ElectricCar myEV = new ElectricCar("Tesla", 2023, 85);
+// myEV.start();
+// myEV.displayDetails();
+// myEV.displayBattery();
+// myEV.stop();
+// }
+// }
diff --git a/11_OOPs/inheritance/Box.java b/11_OOPs/inheritance/Box.java
new file mode 100644
index 0000000..65bfa29
--- /dev/null
+++ b/11_OOPs/inheritance/Box.java
@@ -0,0 +1,31 @@
+// package inheritance;
+
+// public class Box {
+// double l;
+// double w;
+// double h;
+
+// public void information(){
+// System.out.println("Running the box");
+// }
+// public static void main(String[] args) {
+// //Types of inheritance in the java
+// //1. Single Inheritance
+// //2. Multilevel inheritance
+// //> Multiple parent classes for their respective child in a chain order.
+// //>> Thumb rule to understand java is try this and that , not relying on sir to teach
+// //>> in multilevel inheritance, above classes have no idea of their childs but the childs have complete idea of their parents
+
+
+// // Base class with l, h, w (length, height, width).
+
+// // Two constructors:
+
+// // One takes values directly.
+
+// // One is a copy constructor.
+
+// // information() is a sample method.
+
+// }
+// }
diff --git a/11_OOPs/inheritance/BoxPrice.java b/11_OOPs/inheritance/BoxPrice.java
new file mode 100644
index 0000000..cacb17e
--- /dev/null
+++ b/11_OOPs/inheritance/BoxPrice.java
@@ -0,0 +1,30 @@
+// package OOPS.oops3.inheritance;
+
+// public class BoxPrice extends BoxWeight {
+// double cost;
+
+// BoxPrice(){
+// super();
+// this.cost = -1;
+// }
+
+// BoxPrice(BoxPrice other){
+// super(other);
+// this.cost = other.cost;
+// }
+
+// public BoxPrice(double l, double h, double w, double weight, double cost){
+// super(l, h, w, weight);
+// this.cost = cost;
+// }
+
+// public BoxPrice(double side, double weight, double cost){
+// //this method is created later on and no side is defined so make a constructor at the BoxWeight and define the side over there
+// super(side, weight);
+// this.cost = cost;
+// }
+
+// public static void main(String[] args) {
+
+// }
+// }
diff --git a/11_OOPs/inheritance/BoxWeight.java b/11_OOPs/inheritance/BoxWeight.java
new file mode 100644
index 0000000..e39c36f
--- /dev/null
+++ b/11_OOPs/inheritance/BoxWeight.java
@@ -0,0 +1,41 @@
+// package OOPS.oops3.inheritance;
+
+// public class BoxWeight extends Box {
+// double weight;
+
+// public BoxWeight(){
+// super(-1, -1, -1); // Call a valid Box constructor with default values
+// this.weight = -1;
+// }
+
+// BoxWeight(BoxWeight other){
+// super(other); // Call to Box copy constructor
+// weight = other.weight;
+// }
+
+// //creating the constructor for the side
+// BoxWeight(double side, double weight){
+// super(side, side, side); // Added missing part (perfect cube)
+// this.weight = weight;
+// }
+
+// public BoxWeight(double l, double h, double w, double weight){
+// //used to initilaize the values present in the parent class
+// super(l, h, w); // What is this ?? - calling the parent class constructor
+// this.weight = weight;
+// }
+// }
+
+// // Inherits from Box, adds weight.
+
+// // Has:
+
+// // Default constructor
+
+// // Copy constructor (calls super(other) โ Box's copy constructor)
+
+// // Cube constructor (side)
+
+// // Full constructor with all dimensions and weight
+
+// // Uses super(...) to call parent constructors.
diff --git a/11_OOPs/inheritance/Main.java b/11_OOPs/inheritance/Main.java
new file mode 100644
index 0000000..5e009aa
--- /dev/null
+++ b/11_OOPs/inheritance/Main.java
@@ -0,0 +1,58 @@
+// package OOPS.oops3.inheritance;
+
+// public class Main {
+// public static void main(String[] args) {
+// // Creating a BoxPrice object using full constructor
+// BoxPrice item1 = new BoxPrice(2.0, 3.0, 4.0, 5.0, 100.0);
+// System.out.println(item1);
+// // Creating a BoxPrice object using cube constructor
+// BoxPrice item2 = new BoxPrice(5.0, 6.0, 150.0);
+// System.out.println("------");
+// // Creating a copy of BoxPrice object
+// BoxPrice item3 = new BoxPrice(item2);
+
+// // Using inherited method
+// item3.information();
+// }
+// }
+
+
+// // BoxPrice item1 = new BoxPrice(2.0, 3.0, 4.0, 5.0, 100.0);
+// // Calls BoxPrice(double, double, double, double, double)
+
+// // Calls super(l, h, w, weight) in BoxWeight
+
+// // Calls super(l, h, w) in Box
+
+// // Prints: Box class constructor
+
+// // Initializes weight
+
+// // Initializes cost
+
+// // ๐น BoxPrice item2 = new BoxPrice(5.0, 6.0, 150.0);
+// // Calls cube constructor in BoxPrice
+
+// // Calls super(side, weight) โ BoxWeight(double, double)
+
+// // Calls super(side, side, side) โ Box
+
+// // Initializes weight
+
+// // Initializes cost
+
+// // ๐น BoxPrice item3 = new BoxPrice(item2);
+// // Calls copy constructor in BoxPrice
+
+// // Calls super(other) โ BoxWeight(BoxWeight other)
+
+// // Calls super(other) โ Box(Box old)
+
+// // Prints: Box Copy class constructor
+
+// // Copies weight
+
+// // Copies cost
+
+// // ๐น item3.information();
+// // Method from base class Box gets called
diff --git a/11_OOPs/inheritance/Screenshot 2025ๅนด05ๆ31ๆฅ 073139.png b/11_OOPs/inheritance/Screenshot 2025ๅนด05ๆ31ๆฅ 073139.png
new file mode 100644
index 0000000..49ddb42
Binary files /dev/null and b/11_OOPs/inheritance/Screenshot 2025ๅนด05ๆ31ๆฅ 073139.png differ
diff --git a/CollectionFramworks/ListDemo.java b/CollectionFramworks/ListDemo.java
new file mode 100644
index 0000000..057cd58
--- /dev/null
+++ b/CollectionFramworks/ListDemo.java
@@ -0,0 +1,26 @@
+import java.util.ArrayList;
+
+public class ListDemo {
+ public static void main(String[] args) {
+
+ ArrayList students = new ArrayList();
+
+ students.add("alice");
+ students.add("bob");
+ students.add("Jasmine");
+
+ System.out.println("First student: " + students.get(0));
+
+ students.set(1, "Baba");
+
+ for (String myStudent : students) {
+ System.out.println("Student: " + myStudent);
+ }
+
+ System.out.println("Size before removal: " + students.size());
+
+ students.remove(2);
+
+ System.out.println("Size after removal: " + students.size());
+ }
+}
diff --git a/CollectionFramworks/setDemo.java b/CollectionFramworks/setDemo.java
new file mode 100644
index 0000000..e152f97
--- /dev/null
+++ b/CollectionFramworks/setDemo.java
@@ -0,0 +1,25 @@
+
+import java.util.HashSet;
+
+// #setinterface setdemo
+
+//> the setinterface(java.util.set) represents a collection with no duplicates
+//> ex- Hashset(Unorderd), Treeset(sorted)
+
+
+public class setDemo{
+ public static void main(String[] args) {
+ HashSet numbers = new HashSet();
+
+ numbers.add(10);
+ numbers.add(30);
+ numbers.add(10);
+
+ System.out.println("conatians 20?" + numbers.contains(20));
+ for(Integer num: numbers) {
+ System.out.println("Numbers: " + num);
+ }
+ numbers.remove(10);
+ System.out.println("Size after removal: " + numbers.size());
+ }
+}
\ No newline at end of file
diff --git a/Exception_Handling/Demo.java b/Exception_Handling/Demo.java
new file mode 100644
index 0000000..1c6aa1b
--- /dev/null
+++ b/Exception_Handling/Demo.java
@@ -0,0 +1,9 @@
+package Exception_Handling;
+
+public class Demo {
+ public static void main(String[] args) {
+ // you can also use the exception created in any their file and within the same folder.
+
+ ExceptionHandle.divide(3, 4);
+ }
+}
diff --git a/Exception_Handling/ExceptionHandle.java b/Exception_Handling/ExceptionHandle.java
new file mode 100644
index 0000000..32e3e66
--- /dev/null
+++ b/Exception_Handling/ExceptionHandle.java
@@ -0,0 +1,56 @@
+package Exception_Handling;
+
+public class ExceptionHandle {
+ public static void main(String[] args) {
+
+ int a = 5;
+ int b = 0;
+
+ // fancy approach
+ // int c = a/b;
+
+ // optimize approach -> using try-catch
+
+ try {
+ divide(a, b);
+ String name = "Mukesh";
+ if(name.equals("Piyush")) {
+ throw new MyException("name is Piyush");
+ }
+ }
+ catch(MyException e) {
+ System.out.println(e.getMessage()); // Fixed: added parentheses
+ }
+ catch(ArithmeticException e) { // Fixed: correct spelling
+ System.out.println(e.getMessage()); // Fixed: added parentheses
+ }
+ catch(Exception e) {
+ System.out.println("Normal Exception");
+ }
+ finally {
+ System.out.println("it will always be executed");
+ }
+ }
+
+ // Fixed: moved outside main method and corrected 'static'
+ static int divide(int a, int b) throws ArithmeticException {
+ if(b == 0) {
+ throw new ArithmeticException("please do not divide by zero");
+ }
+ return a/b;
+ }
+}
+
+// error is non recoverable in java, program cant handle an error.
+// exception is somthing that prevents the normal flow of the program - like I/O or somthing.
+// In Java, there's a class called "throwable" which is the parent class of all exceptions and errors.
+
+// Exceptions ---> category ----> Error
+// Checked || Unchecked Exceptions
+
+// Checked Exceptions: 1) Happens at compile time
+// 2) for ex- try to open an file which does not exist.
+// 3) for this, we use tyr-catch block, to try all the things, and if something bad happens, we catch is there.
+// 4) In the divide method, we used inbuilt "Arithmatic Exception"
+// 5) These exceptions are not defaulted by the compiler, for ex- arithmatic, normal exceptions, etc. But the more strictly ones have to be called at the top and not at the bottom.
+// 6) created, the myException file, and using it here, my Exception considers calls the super that itself calls the main constructor.
diff --git a/Exception_Handling/MyException.java b/Exception_Handling/MyException.java
new file mode 100644
index 0000000..eb4681b
--- /dev/null
+++ b/Exception_Handling/MyException.java
@@ -0,0 +1,13 @@
+package Exception_Handling;
+
+public class MyException extends Exception {
+
+ // creating a construrctor method below
+ //again go to the ExceptionHandle file and create your custom exception there
+ public MyException(String message){
+ super(message);
+ }
+ public static void main(String[] args) {
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/Arrays/ArrayIntro.java b/Full-CoreJava/Core Java/Arrays/ArrayIntro.java
new file mode 100644
index 0000000..3859d03
--- /dev/null
+++ b/Full-CoreJava/Core Java/Arrays/ArrayIntro.java
@@ -0,0 +1,43 @@
+public class ArrayIntro{
+ public static void main(String[] args) {
+ //Q-Store a roll no
+ int a = 19;
+ //q- store a person;s name
+ String name = "Laksh";
+
+ //Q-store 5 roll numbers , store 500 roll numbers
+ int rollOne = 23;
+ int rollTwo = 12;
+ int rollthree = 18;
+
+ //Syntax:
+ // datatype [] variable_name = new datatype[size];
+ // for storing 5 roll nos now
+ int [] rnos = new int[5];
+ // or directly by
+ int [] rnos2 = {1,2,3,4,5};
+ for (int i=0;i> with this ros is bveing defined in the stack
+ // int[] ros = new int[5]>> actually here object is being created in the memory (heap) (initialization)
+ // int[] ros {happens at compile time} : new int[5] {happens at run time} (this is called dynamic memory allocation)
+ // in java, there's no pointer or something so the java ultimately depends on the jvm for to decide weather elements inside array are continous or not. Now, as per the hava docs we know that -
+ // 1. array objects are stored inside the heap 2. heap objects are not continous 3. Dynamic memory allocation (run time) 4. So, for the conclusion , if you google array objects are the continous data but in java internally, they are not continous depends on the jvm ultimately
+ // the new keyword here is used to create an object
+ // try to ddeclare an array and print the array - you will get 0 at all the indexes when the array is undefined
+ // but in the case of string array> you get null
+ //Reason for the null- String is an reference data type in he java . Now, array of string pointing towards indivudal objects in java. So, if nothing is assigned you get null
+
+ String [] arr2 = new String[4];
+ System.out.println(arr2[0]);
+ System.out.println(rnos[0]);
+ System.out.println(rnos[1]);
+ System.out.println(rnos[2]);
+ System.out.println(rnos[3]);
+
+ System.out.println(rnos2[3]);
+
+ }
+}
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/Arrays/ArrayThree.java b/Full-CoreJava/Core Java/Arrays/ArrayThree.java
new file mode 100644
index 0000000..f6215b6
--- /dev/null
+++ b/Full-CoreJava/Core Java/Arrays/ArrayThree.java
@@ -0,0 +1,21 @@
+import java.util.Arrays;
+import java.util.Scanner;
+
+public class ArrayThree {
+ public static void main(String[] args) {
+ Scanner in = new Scanner(System.in);
+
+ // array of objects
+ String[] str = new String[4];
+ for (int i = 0; i < str.length; i++) { + str[i] = in.next(); + } + + System.out.println(Arrays.toString(str)); + // after modifying the array + str[1] = "Laksh"; + System.out.println(Arrays.toString(str)); + + in.close(); + } +} diff --git a/Full-CoreJava/Core Java/Arrays/ArrayTwo.java b/Full-CoreJava/Core Java/Arrays/ArrayTwo.java new file mode 100644 index 0000000..5dfee30 --- /dev/null +++ b/Full-CoreJava/Core Java/Arrays/ArrayTwo.java @@ -0,0 +1,30 @@ +import java.util.Scanner; + +public class ArrayTwo { + public static void main(String[] args) { + // taking input from the user + Scanner in = new Scanner(System.in); + + int[] originalArr = new int[5]; + originalArr[0] = 23; + originalArr[1] = 45; + originalArr[2] = 233; + originalArr[3] = 543; + originalArr[4] = 3; + System.out.println(originalArr[3]); + + int[] arr = new int[5]; // array to store user input + + // giving the input using the for loops + for (int i = 0; i < arr.length; i++) { + arr[i] = in.nextInt(); + } + + // enhanced for loop - + for (int num : arr) { //for every element in array, print the element + System.out.print(num + " "); //here num represents every element of an array + } + + System.out.println(originalArr[4]); // index out of bound error with this, last digit can be the 5th index + } +} diff --git a/Full-CoreJava/Core Java/Arrays/MultiDimensional.java b/Full-CoreJava/Core Java/Arrays/MultiDimensional.java new file mode 100644 index 0000000..89e863e --- /dev/null +++ b/Full-CoreJava/Core Java/Arrays/MultiDimensional.java @@ -0,0 +1,54 @@ +public class MultiDimensional { + public static void main(String[] args) { + // 1 2 3 + // 4 5 6 + // 7 8 9 + int [][] arr = new int[3][]; + // no. of rows inseration is mandatory and not the column + int[][] arr2 = { + {1,2,3}, + {4,5,6}, + {7,8,9} + }; + int[][] arr3 = { + {1,2}, + {4,5,6}, + {7,8,9,10,11} +}; +// taking inputs in the 2d array +java.util.Scanner sc = new java.util.Scanner(System.in); +for(int i = 0; i < arr.length; i++) { + System.out.print("Enter number of columns for row " + i + ": "); + int cols = sc.nextInt(); + arr[i] = new int[cols]; + + System.out.println("Enter " + cols + " elements for row " + i + ":"); + for(int j = 0; j < cols; j++) { + arr[i][j] = sc.nextInt(); + } +} + +System.out.println("You entered:"); +for(int i = 0; i < arr.length; i++) { + for(int j = 0; j < arr[i].length; j++) { + System.out.print(arr[i][j] + " "); + } + System.out.println(); +} +sc.close(); + + +} +} + + + // Points to remember + // 1. When we create an array (arr) is stored in the stack and the elements ({1,2,3}) are storedi in the heap in java + // 2. An array of arrays + // 3. for ex - arr[1][0]>> [[1,2,3],[4,5,6],[7,8,9]] -> in 2nd row oth index - 4
+ // 4. Size of the column is variable here , its not fixed
+ // 5. for ex- [[1,2,3], [4,5],[6,7,8,9]]>> its because , each array in array of arrays is an differnt object
+ // 6. arr.length>> means the length of rows they are talking about
+ // 7. When itreating the 2d array the outer for loop iterates over each row and in the inner one over each column of each row
+ // 8.arr[i].length - this is in the case of mixed no of columns in each row
+
diff --git a/Full-CoreJava/Core Java/Arrays/MyArrayListDemo.java b/Full-CoreJava/Core Java/Arrays/MyArrayListDemo.java
new file mode 100644
index 0000000..149627c
--- /dev/null
+++ b/Full-CoreJava/Core Java/Arrays/MyArrayListDemo.java
@@ -0,0 +1,47 @@
+import java.util.ArrayList;
+import java.util.Scanner;
+
+public class MyArrayListDemo {
+ // 1. When you dont know , what will be the size of your array and simply telling java please handle my array size and its elements. There comes the array List in the game
+ //2. It is similars to vectors in c++, in java it is a part of the collections framework
+ // 3.Syntax :
+ // 4. Now, here Integer means , what is the type of the data you want to store in the list, so bascially these are the wrapper classes used in the OOPs. You can include primitives directly here, with wrapper classes
+
+ public static void main(String[] args) {
+ Scanner in = new Scanner(System.in);
+ ArrayList list = new ArrayList(5);
+ list.add(78);
+ list.add(79);
+ list.add(500);
+ list.add(45555);
+ list.add(767);
+ list.add(786);
+ list.add(786);
+ list.add(786);
+ list.add(786);
+
+ // Add as many as you want, no fixed size of the array
+ // 1.contains function , helps to find if you're searching for is contained in your list- output -true or false
+
+ System.out.println(list.contains(34));
+ // 2. list.set(index, the no. or elements new value)
+ System.out.println(list.set(1,900 ));
+ // 3. removing the particular element at a particular index
+ System.out.println(list.remove(0));
+ // 4. addding the new elements as an input to the list> getting the items at any index
+ for(int i=0;i<5;i++){ + list.add(in.nextInt()); + } + for(int i=0;i<5;i++){ + System.out.println(list.get(i)); ///pass index here + } + + + System.out.println(list); + } +} + + +// Working of arraylist behind the sscens +//>> arr when you declared it is created in the stack and objects pointing towards the values as reference in the heap
+//>>Size is actually fixed> now, when you fill the array to its capacity> a new arraylist is created with double the capacity and old elements copied to that> old one now is empty and gets destroyed
diff --git a/Full-CoreJava/Core Java/Arrays/ObjectArray.java b/Full-CoreJava/Core Java/Arrays/ObjectArray.java
new file mode 100644
index 0000000..3b3b852
--- /dev/null
+++ b/Full-CoreJava/Core Java/Arrays/ObjectArray.java
@@ -0,0 +1,33 @@
+public class ObjectArray {
+ public static void main(String[] args) {
+ // Step 1: Create an Object array with different data types
+ Object[] mixedArray = {123, "Java", 45.67, true, 'A'};
+
+ // Step 2: Convert each element to String and print it
+ for (Object element : mixedArray) {
+ String str = element.toString(); // toString() is available on every Object
+ System.out.println("Converted to String: " + str);
+ }
+ }
+}
+
+
+// Object[] mixedArray = {...};
+// This creates an array that can hold any type of data, since everything in Java extends Object.
+
+// Elements include:
+
+// 123 (int, autoboxed to Integer)
+
+// "Java" (String)
+
+// 45.67 (double, autoboxed to Double)
+
+// true (boolean, autoboxed to Boolean)
+
+// 'A' (char, autoboxed to Character)
+
+// ๐ธ element.toString()
+// Every class in Java inherits the toString() method from the Object class.
+
+// Primitive values like int, boolean, etc., are autoboxed into their wrapper classes (Integer, Boolean), which override toString() to return a readable string form.
diff --git a/Full-CoreJava/Core Java/Arrays/PassingInFunctions.java b/Full-CoreJava/Core Java/Arrays/PassingInFunctions.java
new file mode 100644
index 0000000..533a86d
--- /dev/null
+++ b/Full-CoreJava/Core Java/Arrays/PassingInFunctions.java
@@ -0,0 +1,18 @@
+import java.util.Arrays;
+
+public class PassingInFunctions {
+ // creating a method
+ // 1. Strings are immutable in java
+ // 2. Arrays are mutable in java
+ // mutablity means, theri values can be modified at the run time
+ static void change(int [] arr){
+ arr[0] = 99;
+ }
+
+ public static void main(String[] args) {
+ int [] nums = {1,2,4,5,6};
+ System.out.println(Arrays.toString(nums));
+ change(nums);
+ System.out.println(Arrays.toString(nums));
+ }
+}
diff --git a/Full-CoreJava/Core Java/Arrays/RandomColumn.java b/Full-CoreJava/Core Java/Arrays/RandomColumn.java
new file mode 100644
index 0000000..449a6d2
--- /dev/null
+++ b/Full-CoreJava/Core Java/Arrays/RandomColumn.java
@@ -0,0 +1,16 @@
+public class RandomColumn {
+ public static void main(String[] args) {
+ int arr[][] = {
+ {1,2,3,4},
+ {5,6},
+ {7,8,9}
+ };
+
+ for(int row=0; row> If i try to swap the primitve values , they wont swap and only pass by reference values swap with each other
+ swap(a, b);
+ swap2(c, d);
+ System.out.println(a+" "+b);
+
+ final A Laksh = new Four.A("Laksh Yadav");
+ Laksh.name = "other name";
+
+
+ }
+ static void swap(int a ,int b){
+ int temp = a;
+ a =b;
+ b=temp;
+ }
+ // but what if i try with the Integer> thats an referene object right ?? , try with that one too
+ static void swap2(Integer c ,Integer d){
+ int temp = c;
+ c =d;
+ d=temp;
+ }
+ // In this calse also they wont swap due to the interal working of the final keyword
+ // final Integer c =10, Integer d = 20 , now cant be swapped
+ // the thing with the final keyword is always initialize while declaring it
+ // the case with the final is you cannot change the value when its primitve data type and for the reference one you can change the data type
+ static class A{
+ final int num = 10;
+ String name;
+ public A(String name){
+ this.name = name;
+ }
+ }
+
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops1/One.java b/Full-CoreJava/Core Java/OOPS/oops1/One.java
new file mode 100644
index 0000000..2f567f6
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops1/One.java
@@ -0,0 +1,49 @@
+package OOPS.oops1;
+
+import java.beans.Statement;
+import java.util.Arrays;
+
+public class One {
+ public static void main(String[] args) {
+ //store 5 roll numbers
+ int [] numbers = new int[5];
+
+ //store 5 names
+ String [] names = new String[5];
+ // 1. Now i want a container to store data - rolno, marks, name
+ //>> Now, what is the wrong approach you will be doing -
+ int [] rollno = new int[5];
+ String [] studentNames = new String[5];
+ float [] marks = new float[5];
+ //>> you have created different objects for all the different entities which is not feasible
+ //>> suppose , what if i want to a data structure in which every single element stores the above (rol,name,marks) . This is where the classes and objects come into the picture
+ //>> One thing is clear from now, if you want to create your own datatype classes are the way.
+ // ==============================================================================================
+ // 2. Now initializing a class
+ Statement[] students = new Statement[5];
+ class Student{
+ int [] rollno = new int[5];
+ String [] studentNames = new String[5];
+ float [] marks = new float[5];
+ }
+
+ //>> Classes are just like an template, for ex- car is an template and from that many companies have created so many brands and cars.
+ //>> for ex- a car can have - seates, engine, price and this is an general template every car has. Like maruti, ferrari, toyotoa etc.
+ // Car templates does not exists physically, though you can find cars and models . the templates are like rule of something car brands has to follow while making a car
+ // By this "1. a class is an template of an object" , "2. an object is an instance of an class"
+ // Classes are just the logical construct , objects are the physical reality
+ // For ex - i have created 3 objects of the class, then those 3 objects have 3 reference variables and with the help of the (.) operator, the reference is linked with the instance variable of the class template
+ // 3. You will get null when try to print the empty object
+ System.out.println(Arrays.toString(students));
+ //>> to see something instead of null , we use new keyword which dynamically allocates memory at run time and returns a reference variable to it.
+ // Student student1 = new Student(); , on LHS 0 it is happening at the compile time(code is exceuting, errors are shown, source code conversion to byte code) , on the RHS it is happening at compile time, means after code verification by jvm it is actuslly running and now the memory is being allocated.
+ // Now, when i do s1.name,s1.roll => it checks weather i have assigned a value and if not it prints the default value instead.
+ // Now, one thing is for sure, there should be a way where all the properties can be assigned in a single line, here laksh.name , laksh.roll, laksh.email,...100 properties i have to write so much
+
+
+
+
+
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops1/Three.java b/Full-CoreJava/Core Java/OOPS/oops1/Three.java
new file mode 100644
index 0000000..79e8ad1
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops1/Three.java
@@ -0,0 +1,39 @@
+package OOPS.oops1;
+
+public class Three {
+ public static void main(String[] args) {
+ //1. Now, creating two objects and pointing to each other is like the reference variables are pointing towards the same object behind the scenes
+ //> for ex- Student one = new Student(), Student two = one;
+ Student one = new Student();
+ Student two = one;
+
+ // Assign values using 'one'
+ one.name = "Something-something";
+ one.age = 20;
+ one.marks = 85.5f;
+
+ // Print values using 'two'
+ System.out.println("two.name: " + two.name);
+ System.out.println("two.age: " + two.age);
+ System.out.println("two.marks: " + two.marks);
+
+ // Modify values using 'two'
+ two.name = "Changed Name";
+ two.age = 22;
+ two.marks = 90.0f;
+
+ // Print values using 'one' to show both references point to the same object
+ System.out.println("one.name: " + one.name);
+ System.out.println("one.age: " + one.age);
+ System.out.println("one.marks: " + one.marks);
+
+ // Check if both references are equal
+ System.out.println("Are 'one' and 'two' referring to the same object? " + (one == two));
+ }
+}
+
+class Student {
+ String name;
+ int age;
+ float marks;
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops1/Two.java b/Full-CoreJava/Core Java/OOPS/oops1/Two.java
new file mode 100644
index 0000000..9b98084
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops1/Two.java
@@ -0,0 +1,42 @@
+package OOPS.oops1;
+
+public class Two {
+ public static void main(String[] args) {
+ //1. That's where the constructor comes into the play
+ // 2. Constructor - a constructor basically defines what happens whenr your object is being created.
+ //>> In other terms, a constructor is an special type of function in class, which binds arguements with the object
+ //>> for ex- Student Laksh = new Student("Laksh Yadav", 13, 64.3)
+ //>> we need one word to access every object. that word will be the "this keyword"
+ //>> for ex- old apporach
+ // Student rahul(){
+ // rahul.name =12;
+ // rahul.age = "hero";
+ // rahul.marks = 88.5f;
+ // }
+
+ // Student rahul(){
+ // this.name =12;
+ // this.age = "hero";
+ // this.marks = 88.5f;
+ // }
+ // for the every new object created, the this keyword takes the name, age, marks of that
+
+ Student s1 = new Student("Laksh Yadav", 13, 64.3f);
+ Student s2 = new Student("Rahul", 15, 88.5f);
+
+ System.out.println(s1.name + " " + s1.age + " " + s1.marks);
+ System.out.println(s2.name + " " + s2.age + " " + s2.marks);
+ }
+}
+
+class Student {
+ String name;
+ int age;
+ float marks;
+
+ Student(String name, int age, float marks) {
+ this.name = name;
+ this.age = age;
+ this.marks = marks;
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/One.java b/Full-CoreJava/Core Java/OOPS/oops2/One.java
new file mode 100644
index 0000000..d60298a
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/One.java
@@ -0,0 +1,10 @@
+package OOPS.oops2;
+
+public class One {
+ // 1. What are packages in java -- packages are just container/boxes of classes. They keep classes in compartments. Its a folder only
+ //2. packages allow you to create same files in different folders.
+ public static void main(String[] args) {
+ System.out.println("Hello World");
+ }
+
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/notes.css b/Full-CoreJava/Core Java/OOPS/oops2/notes.css
new file mode 100644
index 0000000..67530e8
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/notes.css
@@ -0,0 +1,76 @@
+/* 1. EAGER Initialization Singleton
+โ Theory
+In eager initialization, the singleton instance is created as soon as the class is loaded, even if itโs never used.
+
+โ Key Characteristics
+Instance is created at class loading time.
+
+Thread-safe because the class loader mechanism ensures that the instance is created before any thread accesses it.
+
+Fast and simple implementation.
+
+โ When to Use
+When the singleton is always needed.
+
+When instance creation is not resource-intensive.
+
+โ Drawbacks
+If the instance is never used, it results in memory waste.
+
+๐ท 2. LAZY Initialization Singleton
+โ Theory
+In lazy initialization, the instance is created only when itโs needed for the first time.
+
+โ Key Characteristics
+Saves memory by delaying object creation.
+
+Not thread-safe by default โ if two threads call getInstance() simultaneously, two objects could be created.
+
+โ When to Use
+When you want to delay the object creation until itโs absolutely required.
+
+In single-threaded applications.
+
+โ Drawbacks
+Must be manually made thread-safe for use in multi-threaded environments.
+
+๐ท 3. Thread-Safe Singleton (Double-Checked Locking)
+โ Theory
+This version uses lazy initialization with thread-safety by applying synchronization and double-checking before creating the instance.
+
+โ Key Characteristics
+Solves the problem of multiple threads creating separate instances.
+
+Uses synchronized and double-checked locking (check before and after acquiring lock).
+
+volatile keyword ensures that the object is fully initialized before other threads see it.
+
+โ When to Use
+In multi-threaded applications where performance matters.
+
+When you want lazy initialization + thread safety.
+
+โ Drawbacks
+Slightly more complex than other approaches.
+
+๐ท 4. Enum Singleton
+โ Theory
+Java allows a singleton to be implemented using an enum, where the enum itself ensures a single instance is maintained.
+
+โ Key Characteristics
+Simplest and safest way to implement a singleton.
+
+Implicitly thread-safe.
+
+Protects against serialization, reflection, and cloning issues.
+
+โ When to Use
+In modern Java applications where you need a robust, minimal singleton.
+
+When you donโt need lazy initialization but need full safety and simplicity.
+
+โ Drawbacks
+Enum singleton is eagerly initialized by default.
+
+Some developers may find it less intuitive for more complex singleton behavior.
+ */
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/packages/a/Greeting.java b/Full-CoreJava/Core Java/OOPS/oops2/packages/a/Greeting.java
new file mode 100644
index 0000000..60279f0
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/packages/a/Greeting.java
@@ -0,0 +1,9 @@
+package OOPS.oops2.packages.a;
+
+public class Greeting {
+ public static void main(String[] args) {
+ System.out.println("Hello");
+ }
+}
+// With the help of the import statment, you are able to run the java file in the same package
+// Java search for all those items in the other file that are public andd not private and print the results of them
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/packages/b/Greeting.java b/Full-CoreJava/Core Java/OOPS/oops2/packages/b/Greeting.java
new file mode 100644
index 0000000..7b57470
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/packages/b/Greeting.java
@@ -0,0 +1,22 @@
+package OOPS.oops2.packages.b;
+
+import static OOPS.oops2.packages.b.Message.message;
+
+public class Greeting {
+ public static void main(String[] args) {
+ System.out.println("Hello");
+ message();
+ }
+
+ public static void messageGreeting() {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'messageGreeting'");
+ }
+}
+
+
+// Since both classes are in the same package, there's no need to import Greeting in Message.
+
+// Static methods can be called using the class name, e.g., Greeting.messageGreeting();.
+
+// Avoid circular dependency in main() methods โ calling each other back and forth infinitely.
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/packages/b/Message.java b/Full-CoreJava/Core Java/OOPS/oops2/packages/b/Message.java
new file mode 100644
index 0000000..a4b3575
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/packages/b/Message.java
@@ -0,0 +1,15 @@
+// File: Message.java
+package OOPS.oops2.packages.b;
+
+public class Message {
+ public static void message() {
+ System.out.println("This is the message box");
+ }
+
+ public static void main(String[] args) {
+ System.out.println("Inside Message class main()");
+
+ // Call the static method from Greeting class
+ Greeting.messageGreeting(); // No need to import if in same package
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/singleTon/enum/enumSingleton.java b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/enum/enumSingleton.java
new file mode 100644
index 0000000..64daa17
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/enum/enumSingleton.java
@@ -0,0 +1,9 @@
+package OOPS.oops2.singleTon.enum;
+
+public enum enumSingleton {
+ INSTANCE;
+
+ public void log(String message) {
+ System.out.println("Log: " + message);
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/singleTon/enum/enumSingletonTwo.java b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/enum/enumSingletonTwo.java
new file mode 100644
index 0000000..fea9f76
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/enum/enumSingletonTwo.java
@@ -0,0 +1,11 @@
+package OOPS.oops2.singleTon.enum;
+
+public class enumSingletonTwo {
+ public static void main(String[] args) {
+ enumSingleton logger1 = enumSingleton.INSTANCE;
+ enumSingleton logger2 = enumSingleton.INSTANCE;
+
+ logger1.log("System started");
+ System.out.println(logger1 == logger2); // true
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/singleTon/lazyInitialize/singletonLazy.java b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/lazyInitialize/singletonLazy.java
new file mode 100644
index 0000000..3b2e677
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/lazyInitialize/singletonLazy.java
@@ -0,0 +1,22 @@
+package OOPS.oops2.singleTon.lazyInitialize;
+
+public class singletonLazy {
+ private static singletonLazy instance;
+
+ private singletonLazy() {
+ System.out.println("Settings instance created");
+ }
+
+ public static singletonLazy getInstance() {
+ if (instance == null) {
+ instance = new singletonLazy();
+ }
+ return instance;
+ }
+
+ public void displaySettings() {
+ System.out.println("Displaying user settings...");
+ }
+}
+
+
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/singleTon/lazyInitialize/singletonLazyTwo.java b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/lazyInitialize/singletonLazyTwo.java
new file mode 100644
index 0000000..cf985fc
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/lazyInitialize/singletonLazyTwo.java
@@ -0,0 +1,11 @@
+package OOPS.oops2.singleTon.lazyInitialize;
+
+public class singletonLazyTwo {
+ public static void main(String[] args) {
+ singletonLazy s1 = singletonLazy.getInstance();
+ singletonLazy s2 = singletonLazy.getInstance();
+
+ s1.displaySettings();
+ System.out.println(s1 == s2); // true
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/singleTon/regular/Singleton.java b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/regular/Singleton.java
new file mode 100644
index 0000000..043bd27
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/regular/Singleton.java
@@ -0,0 +1,18 @@
+package OOPS.oops2.singleTon.regular;
+
+public class Singleton {
+ private static final Singleton instance = new Singleton();
+
+ private Singleton() {
+ System.out.println("Singleton instance created");
+ }
+
+ public static Singleton getInstance() {
+ return instance;
+ }
+
+ public void showConfig() {
+ System.out.println("Showing configuration");
+ }
+}
+// 1. Initialization of the singleton class in this file
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/singleTon/regular/SingletonTwo.java b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/regular/SingletonTwo.java
new file mode 100644
index 0000000..8c46fff
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/singleTon/regular/SingletonTwo.java
@@ -0,0 +1,12 @@
+package OOPS.oops2.singleTon.regular;
+
+public class SingletonTwo {
+ public static void main(String[] args) {
+ Singleton config1 = Singleton.getInstance();
+ Singleton config2 = Singleton.getInstance();
+
+ config1.showConfig();
+
+ System.out.println(config1 == config2); // true
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/staticExample/Main.java b/Full-CoreJava/Core Java/OOPS/oops2/staticExample/Main.java
new file mode 100644
index 0000000..420a173
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/staticExample/Main.java
@@ -0,0 +1,17 @@
+package OOPS.oops2.staticExample;
+
+public class Main {
+ public static void main(String[] args) {
+ User laksh = new User(22, "Laksh", 30000, false);
+ User rahul = new User(21, "Rahul", 10000, true);
+
+ System.out.println(laksh.name); // Output: Laksh
+ rahul.displayInfo();
+ // System.out.println(laksh.population);
+ // System.out.println(rahul.population);
+ // Not a good convention to use for the static one, instead using
+ System.out.println(User.population);
+ System.out.println(User.population);
+ System.out.println(User.population);
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/staticExample/User.java b/Full-CoreJava/Core Java/OOPS/oops2/staticExample/User.java
new file mode 100644
index 0000000..62417dd
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/staticExample/User.java
@@ -0,0 +1,45 @@
+package OOPS.oops2.staticExample;
+
+public class User {
+ int age;
+ String name;
+ int salary;
+ boolean married;
+ static long population;
+
+ // Constructor
+ public User(int age, String name, int salary, boolean married) {
+ this.age = age;
+ this.name = name;
+ this.salary = salary;
+ this.married = married;
+ // this.population+=1;
+ User.population+=1;
+ }
+
+ // You can optionally add a display method
+ public void displayInfo() {
+ System.out.println(name + " | Age: " + age + " | Salary: " + salary + " | Married: " + married);
+ }
+}
+
+
+// In the User class (or any similar class used to define objects or models), there's no need for a main() method unless you're writing a test or trying to run it independently.
+
+// Import statements are also unnecessary when using classes in the same package, because Java automatically recognizes them within the same package hierarchy.
+
+// those properites that are independent from the objects from which they are being created are called - Static variables . Now, the population is common to both the objects of the parent class. But, there is a doubt, if the static is independent of the object, why used with the this keyword ?? , instead it should be used with the class
+// When the member is decalred static, it can be accessd before any of the objects of the class being created,and without referencing to that object.(ex- laksh.population not needed)
+// **Big Conclusion - now imagine of the public static void main (){}, for anything to run inside a class, you need an object created first. Now, with the static keyword, you can run the main method wihout crating any object
+
+// A static method can only access the static data and not the non static data , for ex- void greeting(){syso - Hello world} - this method belongs to the object
+// // That ultimately means, what will be inside the static main(){}, doesnt depends on the objects and all the non static things depends or belongs to the object
+static void fun(){
+ // greeting(); //cant be called because it requires an instance to call, but the function that you are using it in doesnt requires an object
+ // For this, you have to reference it , as
+ User obj = new User();
+ obj.greeting();
+}
+ void greeting(){
+ System.out.println("Hello");
+ }
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/staticThree/StaticThree.java b/Full-CoreJava/Core Java/OOPS/oops2/staticThree/StaticThree.java
new file mode 100644
index 0000000..fb28de5
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/staticThree/StaticThree.java
@@ -0,0 +1,20 @@
+package OOPS.oops2.staticThree;
+
+public class StaticThree {
+ // 1. outside classes cannot be static
+ // 2. only the inside classes can be static
+
+ static class Test{
+ String name;
+ // creating the constructor here
+ public Test(String name){
+ this.name = name;
+ }
+ }
+ public static void main(String[] args) {
+ Test a = new Test("Laksh");
+ Test b = new Test("Rahul");
+ // because the test class itself depends on its outside classes so the error .
+ // now, use the keyword static ahead of the test
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops2/staticTwo/StaticTwo.java b/Full-CoreJava/Core Java/OOPS/oops2/staticTwo/StaticTwo.java
new file mode 100644
index 0000000..f1b7dc2
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops2/staticTwo/StaticTwo.java
@@ -0,0 +1,22 @@
+package OOPS.oops2.staticTwo;
+
+public class StaticTwo {
+ // 1. This is a demo to show the initialization of the static variable
+ static int a = 4;
+ static int b;
+
+ // this static block will only runs once when the first obj is created. i.e. when the class is loaded for the first time
+
+ static {
+ System.out.println("I am in the static block");
+ b= a*5;
+ }
+ public static void main(String[] args) {
+ StaticTwo obj = new StaticTwo();
+ System.out.println(StaticTwo.a + " "+StaticTwo.b);
+
+ StaticTwo.b +=3;
+ StaticTwo obj2 = new StaticTwo();
+ System.out.println(StaticTwo.a +" "+StaticTwo.b);
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/inheritance.zip b/Full-CoreJava/Core Java/OOPS/oops3/inheritance.zip
new file mode 100644
index 0000000..25b4c28
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops3/inheritance.zip differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Box.java b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Box.java
new file mode 100644
index 0000000..e6f0c1a
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Box.java
@@ -0,0 +1,43 @@
+package OOPS.oops3.inheritance;
+
+public class Box {
+ double l;
+ double w;
+ double h;
+
+ Box(double l, double h, double w){
+ System.out.println("Box class constructor");
+ this.l = l;
+ this.w = w;
+ this.h=h;
+ }
+ Box(Box old){
+ System.out.println("Box Copy class constructor");
+ this.l = old.l;
+ this.w = old.w;
+ this.h=old.h;
+ }
+ public void information(){
+ System.out.println("Running the box");
+ }
+ public static void main(String[] args) {
+ //Types of inheritance in the java
+ //1. Single Inheritance
+ //2. Multilevel inheritance
+ //> Multiple parent classes for their respective child in a chain order.
+ //>> Thumb rule to understand java is try this and that , not relying on sir to teach
+ //>> in multilevel inheritance, above classes have no idea of their childs but the childs have complete idea of their parents
+
+
+// Base class with l, h, w (length, height, width).
+
+// Two constructors:
+
+// One takes values directly.
+
+// One is a copy constructor.
+
+// information() is a sample method.
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/inheritance/BoxPrice.java b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/BoxPrice.java
new file mode 100644
index 0000000..8499b3d
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/BoxPrice.java
@@ -0,0 +1,30 @@
+package OOPS.oops3.inheritance;
+
+public class BoxPrice extends BoxWeight {
+ double cost;
+
+ BoxPrice(){
+ super();
+ this.cost = -1;
+ }
+
+ BoxPrice(BoxPrice other){
+ super(other);
+ this.cost = other.cost;
+ }
+
+ public BoxPrice(double l, double h, double w, double weight, double cost){
+ super(l, h, w, weight);
+ this.cost = cost;
+ }
+
+ public BoxPrice(double side, double weight, double cost){
+ //this method is created later on and no side is defined so make a constructor at the BoxWeight and define the side over there
+ super(side, weight);
+ this.cost = cost;
+ }
+
+ public static void main(String[] args) {
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/inheritance/BoxWeight.java b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/BoxWeight.java
new file mode 100644
index 0000000..a06eb0e
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/BoxWeight.java
@@ -0,0 +1,41 @@
+package OOPS.oops3.inheritance;
+
+public class BoxWeight extends Box {
+ double weight;
+
+ public BoxWeight(){
+ super(-1, -1, -1); // Call a valid Box constructor with default values
+ this.weight = -1;
+ }
+
+ BoxWeight(BoxWeight other){
+ super(other); // Call to Box copy constructor
+ weight = other.weight;
+ }
+
+ //creating the constructor for the side
+ BoxWeight(double side, double weight){
+ super(side, side, side); // Added missing part (perfect cube)
+ this.weight = weight;
+ }
+
+ public BoxWeight(double l, double h, double w, double weight){
+ //used to initilaize the values present in the parent class
+ super(l, h, w); // What is this ?? - calling the parent class constructor
+ this.weight = weight;
+ }
+}
+
+// Inherits from Box, adds weight.
+
+// Has:
+
+// Default constructor
+
+// Copy constructor (calls super(other) โ Box's copy constructor)
+
+// Cube constructor (side)
+
+// Full constructor with all dimensions and weight
+
+// Uses super(...) to call parent constructors.
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Main.java b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Main.java
new file mode 100644
index 0000000..8124f44
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Main.java
@@ -0,0 +1,58 @@
+package OOPS.oops3.inheritance;
+
+public class Main {
+ public static void main(String[] args) {
+ // Creating a BoxPrice object using full constructor
+ BoxPrice item1 = new BoxPrice(2.0, 3.0, 4.0, 5.0, 100.0);
+ System.out.println(item1);
+ // Creating a BoxPrice object using cube constructor
+ BoxPrice item2 = new BoxPrice(5.0, 6.0, 150.0);
+ System.out.println("------");
+ // Creating a copy of BoxPrice object
+ BoxPrice item3 = new BoxPrice(item2);
+
+ // Using inherited method
+ item3.information();
+ }
+}
+
+
+// BoxPrice item1 = new BoxPrice(2.0, 3.0, 4.0, 5.0, 100.0);
+// Calls BoxPrice(double, double, double, double, double)
+
+// Calls super(l, h, w, weight) in BoxWeight
+
+// Calls super(l, h, w) in Box
+
+// Prints: Box class constructor
+
+// Initializes weight
+
+// Initializes cost
+
+// ๐น BoxPrice item2 = new BoxPrice(5.0, 6.0, 150.0);
+// Calls cube constructor in BoxPrice
+
+// Calls super(side, weight) โ BoxWeight(double, double)
+
+// Calls super(side, side, side) โ Box
+
+// Initializes weight
+
+// Initializes cost
+
+// ๐น BoxPrice item3 = new BoxPrice(item2);
+// Calls copy constructor in BoxPrice
+
+// Calls super(other) โ BoxWeight(BoxWeight other)
+
+// Calls super(other) โ Box(Box old)
+
+// Prints: Box Copy class constructor
+
+// Copies weight
+
+// Copies cost
+
+// ๐น item3.information();
+// Method from base class Box gets called
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Screenshot 2025ๅนด05ๆ31ๆฅ 073139.png b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Screenshot 2025ๅนด05ๆ31ๆฅ 073139.png
new file mode 100644
index 0000000..49ddb42
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops3/inheritance/Screenshot 2025ๅนด05ๆ31ๆฅ 073139.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/intro/InheritanceOne.java b/Full-CoreJava/Core Java/OOPS/oops3/intro/InheritanceOne.java
new file mode 100644
index 0000000..7b1a92e
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/intro/InheritanceOne.java
@@ -0,0 +1,46 @@
+package OOPS.oops3.intro;
+
+import javax.swing.Box;
+
+public class InheritanceOne {
+ double l;
+ double w;
+ double h;
+ InheritanceOne(){
+ this.l =-1;
+ this.w=-1;
+ this.h=-1;
+ }
+ //cube
+ InheritanceOne(double side){
+ this.w = side;
+ this.l= side;
+ this.h=side;
+ }
+ // passing three arguements
+ public InheritanceOne(double l,double h,double w){
+ this.l =l;
+ this.w=w;
+ this.h=h;
+ }
+
+InheritanceOne(InheritanceOne old){
+ this.h = old.h;
+ this.l = old.l;
+ this.w = old.w;
+}
+ public void information(){
+ System.out.println("Running the box");
+ }
+
+ public static void main(String[] args) {
+ // 1/ Ineritance simply defines inheriting or deriving the properties from the parent to by the child class
+ // 2. If there's a class which is the base class and any class dervided from base class is the child class.Child class inherits properties (variables, methods etc.) from the base class
+ //3. "extends" keyword is the bridge between the base class and the child class
+ //4. Now, the child class has all the properties of the base class + the properties of its own
+ //5. When defining the constructor , you also need to initliaze the parent class variables also
+ //6.
+
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/intro/InheritanceTwo.java b/Full-CoreJava/Core Java/OOPS/oops3/intro/InheritanceTwo.java
new file mode 100644
index 0000000..884758b
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/intro/InheritanceTwo.java
@@ -0,0 +1,13 @@
+package OOPS.oops3.intro;
+
+public class InheritanceTwo {
+ public static void main(String[] args) {
+ InheritanceOne box = new InheritanceOne();
+ System.out.println(box.l+ " "+ box.w+" "+box.h);
+ InheritanceOne box2 = new InheritanceOne(4);
+ System.out.println(box2.l+ " "+ box2.w+" "+box2.h);
+ InheritanceOne box3 = new InheritanceOne(4.5,5.6,7.7);
+ System.out.println(box3.l+ " "+ box3.w+" "+box3.h);
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/multilevelInheritance/theory.css b/Full-CoreJava/Core Java/OOPS/oops3/multilevelInheritance/theory.css
new file mode 100644
index 0000000..8b2b6dd
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/multilevelInheritance/theory.css
@@ -0,0 +1,15 @@
+/* First of all multiple inheritance is not supported in java
+1. What if there are 3 parent classes and that two parent classes have n=2 (lets assume n is a variable) and n=3, while creating object of the third one , parent 3 object>> object.n ?? which n to call this is the confusion for the child
+/* thats why not supported and instead of this we will be using the interfaces in java
+4. Heirtachial inheritance- one class is being inherited by many other classes
+5. Hybrid Inheritance - it is the combination of single and multilevel inheritance ,(not allowed in java)
+6. a class cannot be its own super class (BoxWeight extends Boxweight not allowed in java)
+
+
+
+
+
+
+
+
+*/
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Animal.java b/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Animal.java
new file mode 100644
index 0000000..bf0f2fd
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Animal.java
@@ -0,0 +1,20 @@
+package OOPS.oops3.publicPrivate;
+
+
+
+public class Animal {
+ private String name = "Generic Animal"; // private: not accessible outside this class
+ public int age = 5; // public: accessible everywhere
+
+ public void displayAge() {
+ System.out.println("Age: " + age);
+ }
+
+ private void secretMethod() {
+ System.out.println("This is a private method in Animal.");
+ }
+
+ public void callPrivateMethod() {
+ secretMethod(); // You can call private method inside its own class
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Dog.java b/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Dog.java
new file mode 100644
index 0000000..2b9040b
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Dog.java
@@ -0,0 +1,25 @@
+package OOPS.oops3.publicPrivate;
+
+public class Dog extends Animal {
+
+ public void bark() {
+ // System.out.println("Name: " + name); // โ Error: 'name' is private in Animal
+ System.out.println("Dog is barking...");
+ System.out.println("Age from Animal class: " + age); // โ public: accessible here
+ }
+
+ public void testPrivateAccess() {
+ // secretMethod(); // โ Error: can't access private method from Animal
+ callPrivateMethod(); // โ Okay: call public method that calls private method
+ }
+}
+
+// 1. There are many variables in both parent and child classes
+// 2. you are given access to variables that are in the ref type i.e. Animal
+// 3. hence , you should have access to all the variables except the private
+//4. this also means that the ones you are trying to access should also be initialized
+//5. but when the obj is iteself is of the type parent class, then how will you call the constructor of child class
+// 6. that means that, parent class ko nahi pta child class mei kitne naye variables aa gye hai, but child ko pta hai ki uske parent mei kya hau and khud mei kya hai
+//7. a child reference object with a parent variable is not allowed in java
+
+
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Main.java b/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Main.java
new file mode 100644
index 0000000..8e55be9
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/publicPrivate/Main.java
@@ -0,0 +1,14 @@
+package OOPS.oops3.publicPrivate;
+
+public class Main {
+ public static void main(String[] args) {
+ Dog d = new Dog();
+ d.bark(); // Works fine
+ d.displayAge(); // Accessing public method of parent
+ d.testPrivateAccess();// Works - indirectly calls private method
+
+ // System.out.println(d.name); // โ 'name' is private
+ System.out.println("Age: " + d.age); // โ public field
+ }
+}
+
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/super/Screenshot 2025ๅนด05ๆ30ๆฅ 111659.png b/Full-CoreJava/Core Java/OOPS/oops3/super/Screenshot 2025ๅนด05ๆ30ๆฅ 111659.png
new file mode 100644
index 0000000..2440553
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops3/super/Screenshot 2025ๅนด05ๆ30ๆฅ 111659.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/super/Screenshot 2025ๅนด05ๆ30ๆฅ 111746.png b/Full-CoreJava/Core Java/OOPS/oops3/super/Screenshot 2025ๅนด05ๆ30ๆฅ 111746.png
new file mode 100644
index 0000000..c7938ab
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops3/super/Screenshot 2025ๅนด05ๆ30ๆฅ 111746.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/super/SuperDemo.java b/Full-CoreJava/Core Java/OOPS/oops3/super/SuperDemo.java
new file mode 100644
index 0000000..a8c71cb
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/super/SuperDemo.java
@@ -0,0 +1,40 @@
+// Superclass
+class Animal {
+ String type = "Animal";
+
+ Animal() {
+ System.out.println("Animal constructor called");
+ }
+
+ void sound() {
+ System.out.println("Animal makes a sound");
+ }
+}
+
+// Subclass
+class Dog extends Animal {
+ String type = "Dog";
+
+ Dog() {
+ super(); // calling parent constructor
+ System.out.println("Dog constructor called");
+ }
+
+ void showType() {
+ System.out.println("Type in child: " + this.type);
+ System.out.println("Type in parent: " + super.type);
+ }
+
+ void sound() {
+ super.sound(); // calling parent class method
+ System.out.println("Dog barks");
+ }
+}
+
+public class SuperDemo {
+ public static void main(String[] args) {
+ Dog dog = new Dog();
+ dog.showType();
+ dog.sound();
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/super/SuperDemoThree.java b/Full-CoreJava/Core Java/OOPS/oops3/super/SuperDemoThree.java
new file mode 100644
index 0000000..9ee3e46
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/super/SuperDemoThree.java
@@ -0,0 +1,44 @@
+// Superclass
+class Payment {
+ double amount;
+
+ Payment(double amount) {
+ this.amount = amount;
+ System.out.println("Payment created for amount: " + amount);
+ }
+
+ void pay() {
+ System.out.println("Processing generic payment...");
+ }
+}
+
+// Subclass
+class CreditCardPayment extends Payment {
+ String cardNumber;
+
+ CreditCardPayment(double amount, String cardNumber) {
+ super(amount); // call parent constructor
+ this.cardNumber = cardNumber;
+ }
+
+ @Override
+ void pay() {
+ super.pay(); // call parent method first
+ System.out.println("Processing credit card payment with card: " + cardNumber);
+ }
+}
+
+public class SuperDemoThree {
+ public static void main(String[] args) {
+ CreditCardPayment ccp = new CreditCardPayment(1000, "1234-5678-9876-5432");
+ ccp.pay();
+ }
+}
+
+
+// Why super is useful here:
+// Calls the parent constructor to initialize the base part of the object.
+
+// Calls the parent's method before adding custom logic.
+
+
diff --git a/Full-CoreJava/Core Java/OOPS/oops3/super/SuperTwoDemo.java b/Full-CoreJava/Core Java/OOPS/oops3/super/SuperTwoDemo.java
new file mode 100644
index 0000000..128fe3e
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops3/super/SuperTwoDemo.java
@@ -0,0 +1,24 @@
+class Employee {
+ String name;
+ double salary;
+
+ Employee(String name, double salary) {
+ this.name = name; // โthisโ refers to the current instance variable
+ this.salary = salary;
+ }
+
+ void showInfo() {
+ System.out.println("Employee: " + this.name);
+ System.out.println("Salary: " + this.salary);
+ }
+}
+
+public class SuperTwoDemo {
+ public static void main(String[] args) {
+ Employee emp = new Employee("John", 50000);
+ emp.showInfo();
+ }
+}
+
+// Why this is useful here:
+// It avoids ambiguity between constructor parameters and instance variables with the same name
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Circle.java b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Circle.java
new file mode 100644
index 0000000..253ef77
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Circle.java
@@ -0,0 +1,7 @@
+package OOPS.oops4.polymorphism;
+
+public class Circle {
+ void area(){
+ System.out.println("Area is 3.14*r*r");
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Main.java b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Main.java
new file mode 100644
index 0000000..25c3a51
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Main.java
@@ -0,0 +1,16 @@
+package OOPS.oops4.polymorphism;
+
+public class Main {
+ public static void main(String[] args) {
+ Shapes shape = new Shapes();
+ Circle circle = new Circle();
+ Triangle triangle = new Triangle();
+ Square square = new Square();
+ Rectangle rectangle = new Rectangle();
+
+ circle.area();
+ square.area();
+ triangle.area();
+ shape.area();
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Numbers.java b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Numbers.java
new file mode 100644
index 0000000..0cb8ad3
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Numbers.java
@@ -0,0 +1,17 @@
+package OOPS.oops4.polymorphism;
+
+public class Numbers {
+ int sum(int a , int b){
+ return a+b;
+ }
+
+ int sum(int a, int b,int c){
+ return a+b+c;
+ }
+ public static void main(String[] args) {
+ Numbers obj = new Numbers();
+ obj.sum(2,3);
+ obj.sum(3,4,5);
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Rectangle.java b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Rectangle.java
new file mode 100644
index 0000000..fbddd91
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Rectangle.java
@@ -0,0 +1,8 @@
+package OOPS.oops4.polymorphism;
+
+public class Rectangle {
+ // this is called annotation, just to check whether a created valid method is being overridden or not
+ void area(){
+ System.out.println("Area of rect is l*b");
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Shapes.java b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Shapes.java
new file mode 100644
index 0000000..4421fce
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Shapes.java
@@ -0,0 +1,7 @@
+package OOPS.oops4.polymorphism;
+
+public class Shapes {
+ void area(){
+ System.out.println("I am in the shapes");
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Square.java b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Square.java
new file mode 100644
index 0000000..24b3474
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Square.java
@@ -0,0 +1,8 @@
+package OOPS.oops4.polymorphism;
+
+public class Square {
+ void area(){
+ System.out.println("Area is : side *side");
+ }
+
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Triangle.java b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Triangle.java
new file mode 100644
index 0000000..a9f2ecc
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/polymorphism/Triangle.java
@@ -0,0 +1,7 @@
+package OOPS.oops4.polymorphism;
+
+public class Triangle {
+ void area(){
+ System.out.println("Area is : 0.5*l*h");
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops4/theory.css b/Full-CoreJava/Core Java/OOPS/oops4/theory.css
new file mode 100644
index 0000000..8c54460
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops4/theory.css
@@ -0,0 +1,24 @@
+/*
+Polymorphism - means many forms or many ways to represrnt
+S-1- Create Shapes as the base class and Circle, triangle, square as its children classses
+S-2- Define the area function in all of them
+S-3- create the main.java for exceution of the code from all of them
+S-4- create objects of all the respective classes and call them
+S-5 Now, square.are -> it will go and find area method inthe square class and if found, return the same
+S-6- - Types of polymorphism in java
+>> Compile time polymorphism (achieved by method overloading) - means for the same method the types, arguements, return types, ordering can be different .For ex- multiple construtors
+>> Run Time polymrphism (Dynamic polymorphism) - achived by method overriding
+
+ S-7- Now, again create a new Rectangle.java and area and use the keyword @override
+>> Override basically , means if the type is the reference variable is the parent class and the object is of the child class or sub class ,
+ Shapes circle = new Circle();
+ Shapes square = new Square();
+ circle.area();
+{Parent object = new Child()>>this is known as Upcasting in java}
+This behind the scene work is done by the mechanism in java called- dynamic method dispatch - it determines which version of the overriden type has to be called (if you try to remove the area method from the shape, then this proces cant happen , because method should be there for dispatch to compare which to show during runtime) - this can be also known as late binding in java (jo last mei hoti hai)
+S-8- final method is simply used when you dont want to override anything
+S-9-final methods are the part of early binding in java because, shuru mei hi final laga diya so that it cant be overridden
+S-10- we also cant be override the static methods . static methods as we know doesnt depends on the objects so they cant be overrided, they will run when created in the class . override depends on objects and static doesnt depends on the objects.
+
+
+*/
diff --git a/Full-CoreJava/Core Java/OOPS/oops5/theory.css b/Full-CoreJava/Core Java/OOPS/oops5/theory.css
new file mode 100644
index 0000000..dcc3ac4
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops5/theory.css
@@ -0,0 +1,11 @@
+/*
+Encapsulation is wrapping up the implementation details of the data members and the methoods inside the class
+Abstraction is hiding the unessary details and showing the valueable information
+For ex- ArrayList (abstract data types) - aap seedhe inke bane banaye method use krlo
+
+
+
+
+
+
+*/
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/ObjectClass.java b/Full-CoreJava/Core Java/OOPS/oops6/ObjectClass.java
new file mode 100644
index 0000000..1448f3e
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/ObjectClass.java
@@ -0,0 +1,81 @@
+package OOPS.oops6;
+
+public class ObjectClass implements Cloneable {
+
+ int value;
+
+
+ //constructor of the class
+ public ObjectClass(int value) {
+ this.value = value;
+ }
+
+ // it gives a number representation of an object
+ @Override
+ public int hashCode() {
+ // Return hash code based on 'value' field
+ // return Integer.hashCode(value);
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ // Check for reference equality
+ if (this == obj) return true;
+
+ // Check for null and class type
+ if (obj == null || getClass() != obj.getClass()) return false;
+
+ // Type cast and compare values
+ ObjectClass that = (ObjectClass) obj;
+ return this.value == that.value;
+ }
+
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ // Call super.clone() and return
+ return super.clone();
+ }
+
+ // to string we have already covered
+ @Override
+ public String toString() {
+ // Return custom string representation
+ return "ObjectClass{value=" + value + "}";
+ }
+
+ // this one is for the garbage collection
+ @Override
+ protected void finalize() throws Throwable {
+ System.out.println("Finalize method called for: " + this);
+ super.finalize();
+ }
+
+ public static void main(String[] args) throws CloneNotSupportedException {
+ ObjectClass obj1 = new ObjectClass(34);
+ ObjectClass obj2 = new ObjectClass(34);
+ ObjectClass obj3 = (ObjectClass) obj1.clone();
+
+ System.out.println("HashCode: " + obj1.hashCode());
+ System.out.println("Equals: " + obj1.equals(obj2));
+ System.out.println("Clone: " + obj3);
+ System.out.println("ToString: " + obj1);
+
+ obj1 = null;
+ obj2 = null;
+ obj3 = null;
+
+ // Request garbage collection (no guarantee it will run immediately)
+ System.gc();
+
+ // Give GC time to potentially invoke finalize (not reliable)
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+}
+
+
+//hashcode is not the address like c++ , instead its just the random integer value
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/Screenshot 2025ๅนด05ๆ31ๆฅ 091231.png b/Full-CoreJava/Core Java/OOPS/oops6/Screenshot 2025ๅนด05ๆ31ๆฅ 091231.png
new file mode 100644
index 0000000..f1b6849
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops6/Screenshot 2025ๅนด05ๆ31ๆฅ 091231.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/A.java b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/A.java
new file mode 100644
index 0000000..4387886
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/A.java
@@ -0,0 +1,27 @@
+package OOPS.oops6.pACKAEGES;
+
+public class A {
+ int num;
+ String name;
+ int[] arr;
+
+ private int num2;
+ //declaring a private variable here
+ //for acessing the private variables we have getter and setter methods in java
+ // getter gets the value and setter sets the value
+ public int getNum(){
+ return num2;
+ }
+
+ public void setNum(int num){
+ this.num = num2;
+ }
+ //calling both the methods inside the main
+
+ public A (int num, String name){
+ this.num = num;
+ this.name = name;
+ this.arr = new int[num];
+ }
+
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/Main.java b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/Main.java
new file mode 100644
index 0000000..becd967
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/Main.java
@@ -0,0 +1,20 @@
+package OOPS.oops6.pACKAEGES;
+
+import java.util.ArrayList;
+
+public class Main {
+ public static void main(String[] args) {
+ A obj = new A (34, "Laksh");
+ //need to do a few things
+ //1. access the data members
+ //2. modify the data members
+
+ ArrayList list = new ArrayList(23);
+ // list.DEFAULT_CAPACITY ;
+ /// shows an error because, behind thescenes this method is private , and it is set to 10, you cant acess it
+ /// // we cant access the reference of an array
+ ///
+ obj.getNum();
+ obj.setNum(15);
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/Main.java b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/Main.java
new file mode 100644
index 0000000..792403f
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/Main.java
@@ -0,0 +1,25 @@
+package OOPS.oops6.pACKAEGES.modifiers;
+
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.Base;
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.SamePackageChild;
+import OOPS.oops6.pACKAEGES.modifiers.packageTwo.DifferentPackageChild;
+
+public class Main {
+ public static void main(String[] args) {
+ Base base = new Base();
+ base.showAccess();
+ System.out.println("----------");
+
+ SamePackageChild spc = new SamePackageChild();
+ spc.accessFromSamePackageChild();
+ System.out.println("----------");
+
+ DifferentPackageChild dpc = new DifferentPackageChild();
+ dpc.accessFromDifferentPackageChild();
+ System.out.println("----------");
+
+ OutsideWorld world = new OutsideWorld();
+ world.accessFromOutsideWorld();
+ }
+}
+
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/OutsideWorld.java b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/OutsideWorld.java
new file mode 100644
index 0000000..73cb149
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/OutsideWorld.java
@@ -0,0 +1,14 @@
+package OOPS.oops6.pACKAEGES.modifiers;
+
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.Base;
+
+public class OutsideWorld {
+ public void accessFromOutsideWorld() {
+ Base obj = new Base();
+ System.out.println("OutsideWorld access:");
+ System.out.println("public: " + obj.publicVar);
+ // System.out.println("protected: " + obj.protectedVar); // โ
+ // System.out.println("default: " + obj.defaultVar); // โ
+ // System.out.println("private: " + obj.privateVar); // โ
+ }
+ };
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageOne/Base.java b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageOne/Base.java
new file mode 100644
index 0000000..3f6e34e
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageOne/Base.java
@@ -0,0 +1,21 @@
+package OOPS.oops6.pACKAEGES.modifiers.packageOne;
+
+
+
+public class Base {
+ public int publicVar = 1;
+ protected int protectedVar = 2;
+ int defaultVar = 3; // package-private
+ private int privateVar = 4;
+
+ public void showAccess() {
+ System.out.println("Base class access:");
+ System.out.println("public: " + publicVar);
+ System.out.println("protected: " + protectedVar);
+ System.out.println("default: " + defaultVar);
+ System.out.println("private: " + privateVar);
+ }
+}
+
+
+
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageOne/SamePackageChild.java b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageOne/SamePackageChild.java
new file mode 100644
index 0000000..b443684
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageOne/SamePackageChild.java
@@ -0,0 +1,12 @@
+package OOPS.oops6.pACKAEGES.modifiers.packageOne;
+
+public class SamePackageChild extends Base {
+ public void accessFromSamePackageChild() {
+ System.out.println("SamePackageChild access:");
+ System.out.println("public: " + publicVar);
+ System.out.println("protected: " + protectedVar);
+ System.out.println("default: " + defaultVar); // โ allowed (same package)
+ // System.out.println("private: " + privateVar); // โ not allowed
+ }
+}
+
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageTwo/DifferentPackageChild.java b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageTwo/DifferentPackageChild.java
new file mode 100644
index 0000000..f7e50ca
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/pACKAEGES/modifiers/packageTwo/DifferentPackageChild.java
@@ -0,0 +1,13 @@
+package OOPS.oops6.pACKAEGES.modifiers.packageTwo;
+
+import OOPS.oops6.pACKAEGES.modifiers.packageOne.Base;
+
+public class DifferentPackageChild extends Base {
+ public void accessFromDifferentPackageChild() {
+ System.out.println("DifferentPackageChild access:");
+ System.out.println("public: " + publicVar);
+ System.out.println("protected: " + protectedVar); // โ inherited access
+ // System.out.println("default: " + defaultVar); // โ not allowed
+ // System.out.println("private: " + privateVar); // โ not allowed
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops6/theory.css b/Full-CoreJava/Core Java/OOPS/oops6/theory.css
new file mode 100644
index 0000000..fb2b46f
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops6/theory.css
@@ -0,0 +1,18 @@
+/*
+Packages are of 2 types in java - 1} are the user defined jo hum har file ke upar likhte hai 2} are the in-built packages in java
+
+a} java.lang package - that contains all the essential stuff for the java
+b} java.io
+c} java.util (it contains the utility classes and all the data structures like arraylist, stringbuilder etc.)
+d} applet (obsolete stuff)
+e} awt(for the graphical user interface not needed)
+f} net package(for working internt of things package)
+
+
+
+
+
+
+
+
+*/
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Daughter.java b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Daughter.java
new file mode 100644
index 0000000..d96f3da
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Daughter.java
@@ -0,0 +1,15 @@
+public class Daughter extends Parent {
+
+ public Daughter(int age){
+ super(age);
+ }
+ @Override
+ void career(String name){
+ System.out.println("I am going to be a nurse");
+ }
+ @Override
+ void partner(String name,int age){
+ System.out.println("I love"+ name+"he is"+ age);
+ }
+ }
+
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Main.java b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Main.java
new file mode 100644
index 0000000..5ec8eb3
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Main.java
@@ -0,0 +1,17 @@
+public class Main {
+
+ public static void main(String[] args) {
+ Son son = new Son(30);
+ son.career("disha");
+
+ son.partner(" disha ", 25);
+
+ // calling the static method
+ son.hello();
+ //calling the normal method here
+ son.normal();
+ Daughter daughter = new Daughter(25);
+ daughter.career(null);
+ daughter.partner(" Harish ", 60);
+ }
+}
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Parent.java b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Parent.java
new file mode 100644
index 0000000..9e18ce5
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Parent.java
@@ -0,0 +1,23 @@
+public abstract class Parent{
+
+ int age;
+ //creating a final
+ final int VALUE;
+
+
+ public Parent(int age){
+ this.age = age;
+ VALUE = 25648;
+ }
+
+ // creating static method
+ static void hello(){
+ System.out.println("Hey");
+ }
+ //creating a normal method
+ void normal(){
+ System.out.println("This is very normal here");
+ }
+ abstract void career(String name);
+ abstract void partner(String name,int age);
+}
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Son.java b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Son.java
new file mode 100644
index 0000000..38c3728
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/abstractClasses/Son.java
@@ -0,0 +1,18 @@
+public class Son extends Parent {
+ //creating a constructor for receving age
+ // first use this as uncomment and then comment it
+ // public Son(int age){
+ // this.age = age;
+ // }
+ public Son(int age){
+ super(age);
+ }
+ @Override
+ void career(String name){
+ System.out.println("I am going to be a doctor");
+ }
+ @Override
+ void partner(String name,int age){
+ System.out.println("I love"+ name+"she is"+ age);
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyBrake.java b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyBrake.java
new file mode 100644
index 0000000..3eb4be8
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyBrake.java
@@ -0,0 +1,5 @@
+package Core Java.OOPS.oops7.interfacess;
+
+public interface MyBrake {
+ void brake();
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyCDPlayer.java b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyCDPlayer.java
new file mode 100644
index 0000000..721b679
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyCDPlayer.java
@@ -0,0 +1,19 @@
+package OOPS.oops7.interfacess;
+
+import Core.MyMedia;
+
+public class MyCDPlayer implements MyMedia {
+
+ @Override
+ public void start(){
+ System.out.println("Music Start");
+ }
+
+ @Override
+ public void stop(){
+ System.out.println("Music Stop");
+ }
+ public static void main(String[] args) {
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyCar.java b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyCar.java
new file mode 100644
index 0000000..15a4484
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyCar.java
@@ -0,0 +1,30 @@
+package Core
+
+import Core.MyBrake;
+import Core.MyEngine;
+
+Java.OOPS.oops7.interfacess;
+
+public class MyCar implements MyEngine ,MyBrake {
+ @Override
+ public void brake(){
+ System.out.println("I brake like a normal car");
+ };
+
+ @Override
+ public void start(){
+ System.out.println("I start like a normal car");
+ };
+
+ @Override
+ public void stop(){
+ System.out.println("I stop like a normal car");
+ };
+
+ @Override
+ public void acc(){
+ System.out.println("I accclearates like a normal car");
+ };
+
+
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyEngine.java b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyEngine.java
new file mode 100644
index 0000000..6f498e3
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyEngine.java
@@ -0,0 +1,11 @@
+package Core Java.OOPS.oops7.interfacess;
+
+public interface MyEngine {
+
+
+ static final int PRICE = 78000;
+
+ void start();
+ void stop();
+ void acc();
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyMain.java b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyMain.java
new file mode 100644
index 0000000..1338730
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyMain.java
@@ -0,0 +1,13 @@
+package OOPS.oops7.interfacess;
+
+public class MyMain {
+ public static void main(String[] args) {
+ Car car = new Car();
+
+ car.acc();
+ car.start();
+ car.stop();
+ }
+}
+
+// We can be creating seperate classes for the seperate functions in the interfaces
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyMedia.java b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyMedia.java
new file mode 100644
index 0000000..96c779a
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyMedia.java
@@ -0,0 +1,6 @@
+package Core Java.OOPS.oops7.interfacess;
+
+public interface MyMedia {
+ void start();
+ void stop();
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyPowerEngine.java b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyPowerEngine.java
new file mode 100644
index 0000000..191d604
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/interfacess/MyPowerEngine.java
@@ -0,0 +1,18 @@
+package OOPS.oops7.interfacess;
+
+import Core.MyEngine;
+
+public class MyPowerEngine implements MyEngine {
+ @Override void start(){
+ System.out.println("Power engine starts");
+ }
+
+ @Override void stop(){
+ System.out.println("Power engine stops");
+ }
+ @Override void acc(){
+ System.out.println("Power engine acc");
+ }
+}
+
+// this is the classic example of the seperate classes with the same interfaces
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-1.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-1.png
new file mode 100644
index 0000000..91386ae
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-1.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-10.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-10.png
new file mode 100644
index 0000000..9b207a1
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-10.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-11.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-11.png
new file mode 100644
index 0000000..a7bd9d0
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-11.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-2.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-2.png
new file mode 100644
index 0000000..97587d6
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-2.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-3.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-3.png
new file mode 100644
index 0000000..0187a3a
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-3.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-4.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-4.png
new file mode 100644
index 0000000..053d1b5
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-4.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-5.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-5.png
new file mode 100644
index 0000000..d686a4f
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-5.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-6.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-6.png
new file mode 100644
index 0000000..ae7c945
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-6.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-7.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-7.png
new file mode 100644
index 0000000..515c147
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-7.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-8.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-8.png
new file mode 100644
index 0000000..0d30d0d
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-8.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-9.png b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-9.png
new file mode 100644
index 0000000..6575a3d
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops7/theory pics/Theory-9.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops7/theory.css b/Full-CoreJava/Core Java/OOPS/oops7/theory.css
new file mode 100644
index 0000000..3e171f6
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops7/theory.css
@@ -0,0 +1,39 @@
+/*
+Abstract Classes -When your function does not have the body, it depends on the child class to provide the body for that function.
+
+>> There are some empty methods and the child class over rides those methods from the parent to use them with their bodies.
+>>syntax : abstract void career(String name)
+>> If a class contains one or more abstract methods, then it should also be changeed to the abstract classs
+
+>>S-1- Create three files Parent,Son and Main.java
+>>S-2- Every child class has to override the abstract memthods of parent
+>>S-3- make parent abstract class and then declare methods and then in son, ovrride those methods
+>>S-4- create a daughter.java and do the same as son
+>>S-5- create objects of Son, daugher in the main and see the use
+>>S-6-can we do it for the variables> yes in parent age variable declaration
+>>S-7- we can also create the constructor of the abstract class Parent>> then replace this by super
+>>S-8- you ccan also create the static methods in the abstract classes(reason: there wil be no objects for the abstract classes) , you can then create the normal method here
+>>S-9- we can also be using the final keyword in the abstract Parent class here, try to use in the son , daugheter
+>>S-10- Interfaces - major difference between a class and an interface is variables in the interfaces are only static and final nothing else. java interface can be created using the "implements" keyword while the classes created using the "extends" keyword
+>>S-11-you can implement , multiple interfaces (multiple inheritances)
+>> Imagine a car which has three subcategories - BRAKE(brake()) , ENGINE(start(),stop(),acclerate()), MEDIA(start(),stop()),
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+*/
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/customArrayList/CustomGenericList.java b/Full-CoreJava/Core Java/OOPS/oops8/customArrayList/CustomGenericList.java
new file mode 100644
index 0000000..714a3bb
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/customArrayList/CustomGenericList.java
@@ -0,0 +1,100 @@
+package OOPS.oops8.customArrayList;
+
+import java.util.ArrayList;
+
+public class CustomGenericList {
+
+ private Object[] data;
+ private static int DEFAULT_SIZE = 10;
+ private int size = 0;
+
+ // S-1- you will get the error while using the T as the bytecode during the compile time is not able to differentiate that what it T here . In the oracle docs its clearly mention that you cant create the instancss of the type parameters
+ // For this - use the Object type in the java
+
+ public CustomGenericList() {
+ this.data = new Object[DEFAULT_SIZE];
+ }
+
+ public void add(T item) {
+ if (isFull()) {
+ resize();
+ }
+ data[size++] = item;
+ }
+
+ private void resize() {
+ Object[] temp = new Object[data.length * 2];
+
+ for (int i = 0; i < data.length; i++) { + temp[i] = data[i]; + } + data = temp; + } + + private boolean isFull() { + return size == data.length; + } + + public T remove() { + @SuppressWarnings("unchecked") + T removed = (T) data[--size]; + return removed; + } + + public T get(int index) { + @SuppressWarnings("unchecked") + T item = (T) data[index]; + return item; + } + + public int size() { + return size; + } + + public void set(int index, T value) { + data[index] = value; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < size; i++) { + sb.append(data[i]); + if (i < size - 1) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + + public static void main(String[] args) { + + ArrayList mylist = new ArrayList();
+ mylist.add(45);
+ mylist.remove(0);
+ // mylist.get(0);
+ mylist.add(99);
+ mylist.set(0, 6789);
+ System.out.println(mylist.get(0));
+ System.out.println(mylist.size());
+ System.out.println(mylist.isEmpty());
+
+ // Use of the non-generic custom list class
+ CustommArrayList mynewlist = new CustommArrayList();
+ mynewlist.add(3);
+ mynewlist.add(5);
+ mynewlist.add(8);
+ System.out.println(mynewlist);
+
+ // โ Now using our truly generic list
+ CustomGenericList list2 = new CustomGenericList();
+ list2.add(100);
+ list2.add(200);
+ list2.add(300);
+ System.out.println(list2);
+ System.out.println("Removed: " + list2.remove());
+ System.out.println("After removal: " + list2);
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/customArrayList/CustommArrayList.java b/Full-CoreJava/Core Java/OOPS/oops8/customArrayList/CustommArrayList.java
new file mode 100644
index 0000000..b631481
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/customArrayList/CustommArrayList.java
@@ -0,0 +1,101 @@
+package OOPS.oops8.customArrayList;
+
+import java.util.ArrayList;
+
+public class CustommArrayList {
+
+ //S-2- Creation of our custom array list
+ private int[] data;
+ private static int DEFAULT_SIZE = 10;
+ private int size = 0; //also working as the index value
+
+ // S-3- creation of the constructor method
+ public CustommArrayList() {
+ this.data = new int[DEFAULT_SIZE];
+ }
+
+ // S-4- declaring the variables in the privte and accessing them in the public
+ // S-5- creating all the things below - resize, length, remove and everything
+ public void add(int num) {
+ if (isFull()) {
+ resize();
+ }
+ data[size++] = num;
+ }
+
+ private void resize() {
+ int[] temp = new int[data.length * 2];
+ //copy the current items in the new array
+ for (int i = 0; i < data.length; i++) { + temp[i] = data[i]; + } + data = temp; + } + + private boolean isFull() { + return size == data.length; + } + + public int remove() { + int removed = data[--size]; + return removed; + } + + public int get(int index) { + return data[index]; + } + + public int size() { + return size; + } + + public void set(int index, int value) { + data[index] = value; + } + + // Added toString method for proper output display + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < size; i++) { + sb.append(data[i]); + if (i < size - 1) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + + public static void main(String[] args) { + + // S-1- This is the array list initialization and also using its predefined methods, can we create an array list on our own which is fully customized + ArrayList mylist = new ArrayList();
+ mylist.add(45);
+ mylist.remove(0);
+ // mylist.get(0); // would throw exception here since list is empty after remove
+ mylist.add(99);
+ mylist.set(0, 6789);
+ System.out.println(mylist.get(0));
+ System.out.println(mylist.size());
+ System.out.println(mylist.isEmpty());
+
+ // S-6- Now calling the newly created custom array list
+ CustommArrayList mynewlist = new CustommArrayList();
+ mynewlist.add(3);
+ mynewlist.add(5);
+ mynewlist.add(8);
+ System.out.println(mynewlist);
+
+ //S-7- in the below example,you cant add string while using the Integer in the code, if you do you will get an error, this is called genereics in java
+ ArrayList list2 = new ArrayList();
+ // list2.add("string");
+
+ //S-8- Drawbacks of my custom arraylist
+ //>> First of all this custom list was for the integers only, for the string and others have to create a new one
+ //>> Seconfly, there's no type safety, like i want to define a boolean list, then only booleans can be storing nothing else.
+
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/Demo.java b/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/Demo.java
new file mode 100644
index 0000000..af10284
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/Demo.java
@@ -0,0 +1,8 @@
+package OOPS.oops8.exceptionHandling;
+
+public class Demo {
+ public static void main(String[] args) {
+ //you can also use the exception created in another file and within the same folder here
+ ExceptionHandle.divide(3, 4);
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/ExceptionHandle.java b/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/ExceptionHandle.java
new file mode 100644
index 0000000..9e0af20
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/ExceptionHandle.java
@@ -0,0 +1,56 @@
+package OOPS.oops8.exceptionHandling;
+
+public class ExceptionHandle {
+ // Error is non recoverable, program cant handle an error
+ // Exception is something that prevents the normal flow of the program - like /0 or something
+ //Java there's a class called (Throwable) which handles all the expcetions>> throwable has 2 subcategories one is expcetion and other is error
+ // Exeception category is further of 2 types - checked and unchecked
+ //Checked exception happens at the compile time - try to opening a file which does not exist thats an example
+ // Unchecked expetion are not detected by the compiler, for ex- the arithmatic exception (/0)
+ //in try-catch it simply means try all these things, and if anything happens bad, then exception is there
+ // finally keyword means ,this will happen no matter what
+ // in the divide method, we used the inbuilt arithmatic expression that shows
+ //you can be using the multiple expressions below - like arithmatic , normal exception but the more stricter ones have to be called at the top not at the bottom
+
+ public static void main(String[] args) {
+ int a = 5;
+ int b = 0;
+ //fancy way to write
+ // int c = a/b;
+ // more prettier apporach is using the try catch block
+ try{
+ // int c = a/b;
+ divide(a,b);
+ // created the myexception file and using it here , myException constructor calls the super that itself calls the main constructor
+ String name = "Mukesh";
+ if(name.equals("Laksh")){
+ throw new MyException("name is Laksh yadav");
+ }
+
+
+ }
+ catch(MatchException e){
+ System.out.println(e.getMessage());
+ }
+ catch(ArithmeticException e){
+ System.out.println(e.getMessage());
+ }catch(Exception e){
+ System.out.println("normal exception");
+ }
+
+ finally{
+ System.out.println("It will always be exceuted");
+ }
+
+
+
+ }
+
+ // creating a divide method
+ static int divide (int a ,int b) throws ArithmeticException{
+ if(b==0){
+ throw new ArithmeticException("please do not divide by zero");
+ }
+ return a/b;
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/MyException.java b/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/MyException.java
new file mode 100644
index 0000000..75b24a7
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/exceptionHandling/MyException.java
@@ -0,0 +1,13 @@
+package OOPS.oops8.exceptionHandling;
+
+public class MyException extends Exception {
+
+ // creating a construrctor method below
+ //again go to the ExceptionHandle file and create your custom exception there
+ public MyException(String message){
+ super(message);
+ }
+ public static void main(String[] args) {
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/GenericInterface.java b/Full-CoreJava/Core Java/OOPS/oops8/generics/GenericInterface.java
new file mode 100644
index 0000000..e73846b
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/generics/GenericInterface.java
@@ -0,0 +1,5 @@
+package OOPS.oops8.generics;
+
+public interface GenericInterface {
+ void display();
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Main.java b/Full-CoreJava/Core Java/OOPS/oops8/generics/Main.java
new file mode 100644
index 0000000..bae0384
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/generics/Main.java
@@ -0,0 +1,6 @@
+package OOPS.oops8.generics;
+
+public class Main implements GenericInterface {
+ @Override
+ public void display(Integer value);
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-1.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-1.png
new file mode 100644
index 0000000..4df9a20
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-1.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-10.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-10.png
new file mode 100644
index 0000000..3f6d95a
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-10.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-11.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-11.png
new file mode 100644
index 0000000..8ee6178
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-11.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-12.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-12.png
new file mode 100644
index 0000000..d832d2e
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-12.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-13.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-13.png
new file mode 100644
index 0000000..0be6505
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-13.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-14.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-14.png
new file mode 100644
index 0000000..f250f2e
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-14.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-15.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-15.png
new file mode 100644
index 0000000..8a9b926
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-15.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-16.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-16.png
new file mode 100644
index 0000000..9f67587
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-16.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-17.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-17.png
new file mode 100644
index 0000000..05e6d92
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-17.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-18.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-18.png
new file mode 100644
index 0000000..fe2c615
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-18.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-19.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-19.png
new file mode 100644
index 0000000..00ce000
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-19.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-2.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-2.png
new file mode 100644
index 0000000..160bae1
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-2.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-20.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-20.png
new file mode 100644
index 0000000..1dbe996
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-20.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-21.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-21.png
new file mode 100644
index 0000000..952030d
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-21.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-22.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-22.png
new file mode 100644
index 0000000..1d38fa3
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-22.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-23.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-23.png
new file mode 100644
index 0000000..e7a636b
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-23.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-24.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-24.png
new file mode 100644
index 0000000..d8defc4
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-24.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-25.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-25.png
new file mode 100644
index 0000000..7de17cd
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-25.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-3.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-3.png
new file mode 100644
index 0000000..bcfae41
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-3.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-4.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-4.png
new file mode 100644
index 0000000..8945db2
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-4.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-5.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-5.png
new file mode 100644
index 0000000..d5f9374
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-5.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-6.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-6.png
new file mode 100644
index 0000000..36ad010
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-6.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-7.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-7.png
new file mode 100644
index 0000000..4d5a51a
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-7.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-8.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-8.png
new file mode 100644
index 0000000..7a33cc1
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-8.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-9.png b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-9.png
new file mode 100644
index 0000000..d190842
Binary files /dev/null and b/Full-CoreJava/Core Java/OOPS/oops8/generics/Theory/Theory-9.png differ
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/generics/comparision/Main.java b/Full-CoreJava/Core Java/OOPS/oops8/generics/comparision/Main.java
new file mode 100644
index 0000000..d3bc842
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/generics/comparision/Main.java
@@ -0,0 +1,17 @@
+package OOPS.oops8.generics.comparision;
+
+import OOPS.oops8.generics.GenericInterface;
+
+public class Main implements GenericInterface{
+ public static void main(String[] args) {
+ Student laksh = new Student(12,89.76f);
+ Student rahul = new Student(13,99.76f);
+ //in the main, created 2 different objects with 2 parameters
+ // Now, if you try the below, java gets confused that marks and roll no has to compare or what ??
+ //For this we uses generic interfaces
+
+ // if(rahul use the for loop and with that for each
+ // S-2- here item represents the every single element of the array
+ // S-3- LHS (arr.foreach) - is containing the parameters and -> RHS containing the body of the function
+ // S-4- Consumer here represents an operation that accepts a single input argument and returns no result. This is a functional interface whose functional method is an object.
+ // S-5- created a consumer and assigned an operation to it
+ // S-6- Lambda expressions can be assigned to variables that are typed interfaces
+
+ public static void main(String[] args) {
+ ArrayList arr = new ArrayList();
+ for (int i = 0; i < 5; i++) { + arr.add(i + 1); // adds 1 to 5 + } + + // Lambda in forEach directly + arr.forEach((item) -> {
+ System.out.println(item * 2);
+ });
+
+ // Using Consumer Functional Interface
+ Consumer fun = (item) -> System.out.println(item * 2);
+ arr.forEach(fun);
+
+ // Lambda expressions for arithmetic operations
+ Operation sum = (a, b) -> a + b;
+ Operation subtract = (a, b) -> a - b;
+ Operation multiply = (a, b) -> a * b;
+ Operation divide = (a, b) -> a / b;
+
+ Lambda myCalculator = new Lambda();
+ System.out.println(myCalculator.operate(5, 3, sum));
+ System.out.println(myCalculator.operate(5, 3, subtract));
+ System.out.println(myCalculator.operate(5, 3, multiply));
+ System.out.println(myCalculator.operate(5, 3, divide));
+ }
+
+ // Custom method that takes two numbers and a lambda operation
+ private int operate(int a, int b, Operation op) {
+ return op.operation(a, b);
+ }
+}
+
+// Functional Interface to perform operations
+interface Operation {
+ int operation(int a, int b);
+}
+
+
+/*
+================ EXPLANATION ==================
+
+1. STEP-BY-STEP FLOW:
+-----------------------
+- We create an ArrayList and populate it with numbers 1 through 5.
+- First, we use a lambda expression directly inside `forEach` to print each item multiplied by 2.
+- Then, we define a `Consumer` lambda and pass it to `forEach` for the same result.
+- We define several `Operation` lambda expressions for sum, subtract, multiply, and divide.
+- These are passed to a method `operate(int a, int b, Operation op)` which applies the lambda operation and returns the result.
+- This demonstrates functional programming using lambdas and functional interfaces.
+
+2. DEFINITIONS & PURPOSE:
+----------------------------
+
+- Lambda Expression:
+ A short block of code which takes in parameters and returns a value. Used to implement methods of functional interfaces concisely.
+
+- Functional Interface:
+ An interface with a single abstract method. Allows lambda expressions to provide implementations for that method.
+ (e.g., `Operation`, `Consumer`)
+
+- Consumer:
+ A predefined functional interface in `java.util.function` package. It accepts a single input and returns nothing (void).
+ Syntax: `Consumer c = (item) -> System.out.println(item);`
+
+- Operation Interface:
+ Custom functional interface created to perform operations like sum, subtract, etc. Using it allows us to pass operations as arguments.
+
+- forEach():
+ A method available for collections like ArrayList to iterate each element. Works well with lambdas.
+
+- Lambda `operate()` method:
+ This method demonstrates higher-order functions (passing functions as parameters) in Java.
+
+3. WHY USE THIS APPROACH:
+-----------------------------
+- Cleaner and more concise code.
+- Avoids creating multiple subclasses or anonymous inner classes.
+- Promotes use of modern Java features for better readability and modular code.
+- Useful for APIs that expect functional interfaces (like `forEach`, `stream`, `map`, etc.)
+
+============================================
+*/
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/objectCloning/Human.java b/Full-CoreJava/Core Java/OOPS/oops8/objectCloning/Human.java
new file mode 100644
index 0000000..d74466b
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/objectCloning/Human.java
@@ -0,0 +1,27 @@
+package OOPS.oops8.objectCloning;
+
+public class Human implements Cloneable {
+ int age;
+ String name;
+
+ //creating the normal constructor here
+ public Human(int age, String name){
+ this.age = age;
+ this.name = name;
+ }
+
+ //creating the copy constructor here
+ public Human(Human other){
+ this.age = other.age;
+ this.name = other.name;
+ }
+
+ // for cloning, writing the piece of code here
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ //whatever you are trying to clone throwws some exception and you have to specifically mention that above
+ return super.clone();
+ }
+
+ //creating the Main.java file now
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops8/objectCloning/Main.java b/Full-CoreJava/Core Java/OOPS/oops8/objectCloning/Main.java
new file mode 100644
index 0000000..3737e4d
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops8/objectCloning/Main.java
@@ -0,0 +1,17 @@
+package OOPS.oops8.objectCloning;
+
+public class Main {
+ public static void main(String[] args) throws CloneNotSupportedException {
+ Human Laksh = new Human(34,"Laksh Yadav");
+ //first one calls the normal constructor and second one calls the copy constructor in which in param we have to pass the first object for the copy
+ // in java , there;s an interface that is called clonable which we have to use for , that will be implementated in the Human .java file
+ // Human twin = new Human(Laksh);
+ //first do the above and then comment it and then , if you do the below, on the clone keyword you will get the error and to resolve that "CloneNotSupportedException" you need to sepcivially mention the exceotion
+ Human twin = (Human) Laksh.clone();
+ System.out.println(twin.age + " "+ twin.name);
+ //clone will actually copy the value from one object to the other object
+ //lastly add the implements Clonable in the Human.java file>>> why to add this ?? its just the way to tell the jvm that we are just performing clone on the object of the type Human
+
+ }
+ //To make your cloning code run properly, you need to implement the Cloneable interface in your Human class. Without this, super.clone() will throw a CloneNotSupportedException, even if you handle it with throws.
+}
diff --git a/Full-CoreJava/Core Java/OOPS/oops9/MyCollections.java b/Full-CoreJava/Core Java/OOPS/oops9/MyCollections.java
new file mode 100644
index 0000000..8bb437a
--- /dev/null
+++ b/Full-CoreJava/Core Java/OOPS/oops9/MyCollections.java
@@ -0,0 +1,33 @@
+package OOPS.oops9;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Vector;
+
+public class MyCollections {
+ //Collections framework in java is helping us providing a single interface which includes the common crud methods which all the other dataStructures have like - Maps, Trees ,Queues etc. like the crud operations or something.
+ //There are two major interfacecs in the JAVA - one is the collections framework and other one is the Maps
+ //Also draw the diagram of the flowchart
+ //collections are alreaddy present in the java.util package
+ // Simply aise smjho- ArrayList, StringBuilder etc, mei jo add, remove, edit ke methods hote hai woh common hote hai , so java was like - let me put all the common things inside an interface.
+ //For ex- List extends the Collection>> simply means the methodds in the list are also contained in the Collections , so to utlize them
+ // see list.add or list2.add> both have common methods , thats the beauty
+ // Now, ArrayList and Vector what is the key difference between both of them>> in arraylist, multiple threads in the java can access the array object easily, but in the case of the vector, if one thread has the access , the second one has to wait in line to finish the
+
+ public static void main(String[] args) {
+ List list = new ArrayList();
+ List list2 = new LinkedList();
+ list.add(34);
+ list2.add(84);
+ list.add(56);
+ list2.add(76);
+
+ System.out.println(list2);
+ //creating a vector to demonstrate - they are not as fast as the arralist
+ List vector = new Vector();
+ vector.add(5);
+ vector.add(10);
+ vector.add(15);
+ }
+}
diff --git a/Full-CoreJava/Core Java/Strings/StringFive.java b/Full-CoreJava/Core Java/Strings/StringFive.java
new file mode 100644
index 0000000..cc95779
--- /dev/null
+++ b/Full-CoreJava/Core Java/Strings/StringFive.java
@@ -0,0 +1,21 @@
+package Strings;
+
+public class StringFive {
+ public static void main(String[] args) {
+ String series = " ";
+ for (int i = 0; i<26;i++ ){ + char ch = (char)('a'+i); + series = series+ch; + } + System.out.println(series); + } +} + +// after 1st iteration - ""> "a"
+// after 2nd iteration - "a"> "ab"... so on
+// as we know that strings are immutable in java, on every iteration of the loop a new string object is created and the old values of the object are being copied to the new one.
+// this is not an optimal solution for the performance as the old objects are getting dereferenced everytime i am adding a new string object
+// Total wastage of space - a, ab,abc,abcd,abcde... till 26 because only the 26 th one matters to me
+// Time complexity - 0(N square)
+// The only solution to this is an is there a datatype which can allow me to modify its value ??? Strings are immutable and they can not be modified once created.
+// Teh solution is an -StringBuilder class
diff --git a/Full-CoreJava/Core Java/Strings/StringFour.java b/Full-CoreJava/Core Java/Strings/StringFour.java
new file mode 100644
index 0000000..d2fde8e
--- /dev/null
+++ b/Full-CoreJava/Core Java/Strings/StringFour.java
@@ -0,0 +1,24 @@
+package Strings;
+
+import java.util.ArrayList;
+
+public class StringFour {
+ public static void main(String[] args) {
+ System.out.println('a'+'b');
+ // 1. The operator behind the scences is converting these alphabets into their ascii value form
+ System.out.println("a"+"b");
+ // 2. in this case, string concatenation is taking place here
+ System.out.println((char) ('a'+4));
+ // 3. a. now, string will not be converting to the ascii value, then what will be happening below -
+ System.out.println("a"+ 1);
+ // 3 .b.>>Note - integer will be converted to the integer that will call toString()
+ System.out.println("Laksh"+ new ArrayList());
+ // 4. for the above one you will see an empty array
+ System.out.println(new Integer(56) + new ArrayList());
+ // 5. for the above one - you will be seeing an error because the operator(+) in java is only defined for the primitives and if one of these values is a string. The above thins (before + and after) is an complete experession, so one of them should be the string. Now , if we add an empty string -
+ System.out.println(new Integer(56) + ""+ new ArrayList());
+ // 6. with this its clear that the + operator is a part of the operator overloading in java
+
+
+ }
+}
diff --git a/Full-CoreJava/Core Java/Strings/StringIntro.java b/Full-CoreJava/Core Java/Strings/StringIntro.java
new file mode 100644
index 0000000..a3f7959
--- /dev/null
+++ b/Full-CoreJava/Core Java/Strings/StringIntro.java
@@ -0,0 +1,29 @@
+package Strings;
+
+public class StringIntro{
+ public static void main(String[] args) {
+ int[] arr = {2,3,5,4,19};
+ int a = 10;
+ String name ="Laksh Yadav";
+ System.out.println(name);
+
+ String b = "Laksh";
+ b = "Yadav";
+ System.out.println(b);
+ }
+}
+
+
+
+// Points to Remember :
+// 1. Everything that starts with a capital letter "S" is a class in java
+// 2. When you see the syntax of the string it is : Datatype refernce variable = string object
+// 3. There are important concepts behind working in a string , these are -
+ //>>a.} String Pool b.} Immutablity
+ // a.} Working of the String Pool -
+ //> String pool is the storage data structure inside the heap memory. It is used to store the string objects. Now, to optimize this data structure , it prevents the entry of duplicate copies into the pool. For ex - String name = "Kunal" , String b = "Kunal">> now both name and b are pointing towards a single object in the string pool ,i.e. Kunal , no seperate name and b objects.
+ //> now, some of you might doubt that what if i want to change this object, that will affect both the references pointing towards this object. To them, my answer is no, you cant change. Beause, strings are immutable in javva, once assigned a value , to modify ,create a new one.
+ //> As i see in line 10, created an string object with b as its reference, now assigned b with a new string - yadav, you will see that the old one is modified and the latest change is preserved. For this, when i wrote b = yadav, then in the string pool , i created another object yadav along side laksh and b is pointing towards both the objects now.
+ //> Why we cant modify the string objects ??? Simply, for n number of person string with value as "laksh", now all are pointing towards the laksh object in the string pool, if suppose i try to rename the object for person 2, then all other persons will get affected if no copies or different objects are created. So, for security reasons, its not allowed
+
+
\ No newline at end of file
diff --git a/Full-CoreJava/Core Java/Strings/StringOne.java b/Full-CoreJava/Core Java/Strings/StringOne.java
new file mode 100644
index 0000000..e127f33
--- /dev/null
+++ b/Full-CoreJava/Core Java/Strings/StringOne.java
@@ -0,0 +1,22 @@
+package Strings;
+
+public class StringOne {
+ public static void main(String[] args) {
+ String a = "Laksh";
+ String b = "Laksh";
+
+ // 1. Comparision check (==) {This checks if reference variables (a,b) are pointing towards the same object}
+ System.out.println(a==b);
+ // 2. Now, if you dont want that both a and b refernce variables to point towards the same objec, we have to tell the java that, i want to create a new object even for the same name explicitly. This can only be achived with the help of "new" keyword in java. The new keyword will be creating new object and both thee same objects will be now outside the String pool but inside the heap only. They will be giving false on comparison check because, now they both are pointing towards differnt objects
+ String c = new String("Laksh");
+ String d = new String("Laksh");
+ System.out.println(c==d);
+
+ // 3. When you only need to check on the value use (.equals) method . It will just check the value only
+ String name1 = new String("Hero");
+ String name2 = new String("Hero");
+ System.out.println(name1==name2);
+ System.out.println(name1.equals(name2));
+ System.out.println(name1.charAt(0));
+ }
+}
diff --git a/Full-CoreJava/Core Java/Strings/StringSeven.java b/Full-CoreJava/Core Java/Strings/StringSeven.java
new file mode 100644
index 0000000..a07aa61
--- /dev/null
+++ b/Full-CoreJava/Core Java/Strings/StringSeven.java
@@ -0,0 +1,29 @@
+package Strings;
+
+import java.util.Arrays;
+
+public class StringSeven {
+ public static void main(String[] args) {
+ // String Method 1 in Java
+ String name = "Laksh Yadav";
+ System.out.println(Arrays.toString(name.toCharArray()));
+
+ // String method 2: length()
+ System.out.println("Length: " + name.length());
+
+ // String method 3: toUpperCase()
+ System.out.println("Uppercase: " + name.toUpperCase());
+
+ // String method 4: toLowerCase()
+ System.out.println("Lowercase: " + name.toLowerCase());
+
+ // String method 5: substring()
+ System.out.println("Substring (0,5): " + name.substring(0, 5));
+
+ // String method 6: indexOf()
+ System.out.println("Index of 'Y': " + name.indexOf('Y'));
+
+ // String method 7: replace()
+ System.out.println("Replace 'a' with 'o': " + name.replace('a', 'o'));
+ }
+}
diff --git a/Full-CoreJava/Core Java/Strings/StringSix.java b/Full-CoreJava/Core Java/Strings/StringSix.java
new file mode 100644
index 0000000..b9863d9
--- /dev/null
+++ b/Full-CoreJava/Core Java/Strings/StringSix.java
@@ -0,0 +1,15 @@
+package Strings;
+
+public class StringSix {
+ public static void main(String[] args) {
+ StringBuilder builder = new StringBuilder();
+ for(int i = 0;i<26; i++){ + char ch = (char)('a'+i); + builder.append(ch); + } + System.out.println(builder.toString()); + builder.deleteCharAt(0); + System.out.println(builder); + // try to explore as many builder functions as you can + } +} diff --git a/Full-CoreJava/Core Java/Strings/StringThree.java b/Full-CoreJava/Core Java/Strings/StringThree.java new file mode 100644 index 0000000..a5b02c8 --- /dev/null +++ b/Full-CoreJava/Core Java/Strings/StringThree.java @@ -0,0 +1,11 @@ +package Strings; + +public class StringThree { + public static void main(String[] args) { + // 1. printing the decimal point values + float a = 45.1234f; + System.out.printf("Formatted number is %.2f\n", a); + System.out.printf("The output is %.2f\n", Math.PI); + // 2. You can also explore the list of placeholders on your own -Google it + } +} diff --git a/Full-CoreJava/Core Java/Strings/StringTwo.java b/Full-CoreJava/Core Java/Strings/StringTwo.java new file mode 100644 index 0000000..0beaa65 --- /dev/null +++ b/Full-CoreJava/Core Java/Strings/StringTwo.java @@ -0,0 +1,17 @@ +package Strings; + +import java.util.Arrays; + +public class StringTwo { + public static void main(String[] args) { + System.out.println(56); + System.out.println("Kunal"); + System.out.println(new int[] {1,2,3,4}); + // for exceuting everycommand in the println> it is calling the "return Integer.toString method"
+ // if it is null object, print null otherwise print the toString
+ // Everytime i use println or pass something to it>> it calles the .value> then with conditional operator checks wether the obj is null if it's not null>> obj.toString
+ // in the above one, when you try to print an array like this, the response you re seeing in the console is the textual respresentation of an object
+ // To avoid this, we tell java that no need of your default toString when i have my own (Arrrays.toString())>> this is called function/methood overriding>> now you will see a nice representation of your array
+ System.out.println(Arrays.toString(new int[] {1,2,3,4}));
+ }
+}
diff --git a/Java@Groot.iml b/Java@Groot.iml
new file mode 100644
index 0000000..0761d5c
--- /dev/null
+++ b/Java@Groot.iml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..63acdb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2025 Piyush64-bit
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/LamdaExpression/Main.java b/LamdaExpression/Main.java
new file mode 100644
index 0000000..a5fe464
--- /dev/null
+++ b/LamdaExpression/Main.java
@@ -0,0 +1,16 @@
+@FunctionalInterface
+interface MathOperation {
+ int operation(int a, int b);
+}
+
+public class Main {
+ public static void main(String[] args) {
+ MathOperation add = (a, b) -> a + b;
+ MathOperation multiply = (a, b) -> a * b;
+
+ System.out.println(add.operation(5, 3));
+ System.out.println(multiply.operation(5, 3));
+ }
+}
+
+// a lambda expession can be used wherever function is excepted
\ No newline at end of file
diff --git a/LamdaExpression/NOTES.txt b/LamdaExpression/NOTES.txt
new file mode 100644
index 0000000..14ed14d
--- /dev/null
+++ b/LamdaExpression/NOTES.txt
@@ -0,0 +1,23 @@
+#Lambda Expression in JAVA
+
+-> Lambda expression were introduced in JAVA8 to provide a concise way to represent anonymous functions.
+-> They are primarly used to implement functions interfaces.
+
+-> Syntax are primarly used to implemnt functions interfaces.
+
+-> Syntax:
+(parameter) -> expression
+(parameter) -> {statement}
+
+=> Parameterized: input to the Lambda
+=> (->) arrow operator: seperates parameters from the body
+=> Body: Code to executed
+
+a) Lambda exp. witrh Opera
+()-> System.out.println("Hello World);
+
+b) Lanbda exp with one par.
+x->x=/x
+
+c) Lambda exp. with multiple
+(a, b) -> a+b
\ No newline at end of file
diff --git a/OOPs/Abstract/Daughter.java b/OOPs/Abstract/Daughter.java
new file mode 100644
index 0000000..4b6433b
--- /dev/null
+++ b/OOPs/Abstract/Daughter.java
@@ -0,0 +1,15 @@
+package OOPs.Abstract;
+
+public class Daughter extends Parent {
+ public Daughter(int age){
+ super (age);
+ }
+ @Override
+ void carrer(String name) {
+ System.out.println(name: "going to be a data");
+ }
+ @Override
+ void parent(String name, int age) {
+ System.out.println("I love " + name + "she is " + age _ "years old.");
+ }
+}
diff --git a/OOPs/Abstract/Main.java b/OOPs/Abstract/Main.java
new file mode 100644
index 0000000..000314a
--- /dev/null
+++ b/OOPs/Abstract/Main.java
@@ -0,0 +1,16 @@
+package OOPs.Abstract;
+
+public class Main {
+ public static void main(String[] args) {
+ Son myson = new sun(30);
+ Son.carrer("Aman");
+ Son.parent("Disha", 25);
+
+ Daughter myDaughter = new Daughter(40);
+ myDaughter.carrer("Rakhi");
+ myDaughter.parent("Disha", 25);
+
+ myson.hello();
+ myson.normal();
+ }
+}
diff --git a/OOPs/Abstract/Parent.java b/OOPs/Abstract/Parent.java
new file mode 100644
index 0000000..06e1901
--- /dev/null
+++ b/OOPs/Abstract/Parent.java
@@ -0,0 +1,22 @@
+package OOPs.Abstract;
+
+public abstract class Parent {
+ int age;
+ final int Value;
+
+ public int Parent(int age){
+ this.age = age;
+ Value = 24356;
+ }
+ // creating a static method
+ static void hello() {
+ System.out.println("Hey");
+ }
+ // creating a normal method
+ void normal() {
+ System.out.println("This is normal");
+ }
+ abstract void carrer(String name);
+ abstract void parent(String name, int age);
+
+}
diff --git a/OOPs/Abstract/Son.java b/OOPs/Abstract/Son.java
new file mode 100644
index 0000000..9645cda
--- /dev/null
+++ b/OOPs/Abstract/Son.java
@@ -0,0 +1,15 @@
+package OOPs.Abstract;
+
+public class Son extends Parent {
+ public Son(int age){
+ super (age);
+ }
+ @Override
+ void carrer(String name) {
+ System.out.println(name: "going to be a data");
+ }
+ @Override
+ void parent(String name, int age) {
+ System.out.println("I love " + name + "she is " + age _ "years old.");
+ }
+}
diff --git a/OOPs/GenericInterface/Example.java b/OOPs/GenericInterface/Example.java
new file mode 100644
index 0000000..3306d79
--- /dev/null
+++ b/OOPs/GenericInterface/Example.java
@@ -0,0 +1,16 @@
+// Example of a generic method in Java
+package OOPs.GenericInterface;
+
+public class Example {
+ public static void printArray(T[] array) {
+ for (T element: array) {
+ System.out.println(element);
+ }
+ }
+ public static void main(String[] args) {
+ Integer[] intArray = {1, 2, 3};
+ String[] strArray = {"A", "B", "C"};
+ printArray(intArray);
+ printArray(strArray);
+ }
+}
diff --git a/OOPs/GenericInterface/New.java b/OOPs/GenericInterface/New.java
new file mode 100644
index 0000000..6b1f886
--- /dev/null
+++ b/OOPs/GenericInterface/New.java
@@ -0,0 +1,31 @@
+// new.java genericinterface
+package OOPs.GenericInterface;
+
+class Human implements Cloneable {
+ int age;
+ String name;
+
+ public Human(int age, String name) {
+ this.age = age;
+ this.name = name;
+ }
+
+ public Human(Human override) {
+ this.age = override.age;
+ this.name = override.name;
+ }
+
+ @Override // override
+ protected Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
+
+public class New {
+ public static void main(String[] args) throws CloneNotSupportedException {
+ Human S1 = new Human(20, "Groot");
+ Human S2 = (Human) S1.clone();
+ System.out.println("Original: " + S1.name + ", Age: " + S1.age);
+ System.out.println("Cloned: " + S2.name + ", Age: " + S2.age);
+ }
+}
\ No newline at end of file
diff --git a/OOPs/GenericInterface/Notes.txt b/OOPs/GenericInterface/Notes.txt
new file mode 100644
index 0000000..0e0da4c
--- /dev/null
+++ b/OOPs/GenericInterface/Notes.txt
@@ -0,0 +1,25 @@
+#raw type
+
+a raw type is a generic class or interface used without specifying a type parameter.
+for ex- list instead os list. They are discouged because of bypassing type safty.
+
+list rawlist = new arraylist(); // rawtype;
+rawlist.add ("string");
+rawlist.add(1, 2, 3); ---> no error
+
+
+# Type Erasure:
+a) complile type typing cheacking:
+---> java compiler uses the generic typr information () to enforce type safty at compiler time. This prevents you from putting the wrong type of object into a generic class or methods.
+
+b) Erasure of thpe parameters:
+---> When the code is compile, the compiler removes "all information related to generic type parameters"
+----> If the type parameter is unbounded (T)---> replaced by object
+ bound (T extends number)---> it is replaced by first bound.
+
+c) Insertion of casts:
+---> When you use a generic class, for ex - (Genericlas ), the compiler inserts type casters where nessary to ensure type safety.
+
+ex- Genericlas Strobj = new Genericlas();
+ Strobj.data = "Hello";
+ String value = (String) Strobj.data ---> complier inserts casts
\ No newline at end of file
diff --git a/OOPs/Generics/One.java b/OOPs/Generics/One.java
new file mode 100644
index 0000000..8cd5571
--- /dev/null
+++ b/OOPs/Generics/One.java
@@ -0,0 +1,25 @@
+//generics in java
+package OOPs.Generics;
+
+public class new {
+
+public void PrintList(List > mylist){
+ for(Object item : mylist){
+ System.out.println(item);
+ }
+}
+
+public double sumList(List extends Number> mylist){
+ double sum = 0.0 ;
+ for(Number num :mylist){
+ sum+= num.doubleValue();
+ }
+ return sum;
+}
+
+public class One {
+ public static void main(String[] args) {
+
+ }
+}
+}
diff --git a/OOPs/Generics/Pair.java b/OOPs/Generics/Pair.java
new file mode 100644
index 0000000..b366a18
--- /dev/null
+++ b/OOPs/Generics/Pair.java
@@ -0,0 +1,22 @@
+public class Pair {
+ private K key;
+ private V value;
+
+ public Pair(K key, V value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public K getKey() {
+ return key;
+ }
+
+ public V getValue() {
+ return value;
+ }
+
+ public static void main(String[] args) {
+ Pair pair = new Pair("Age", 25);
+ System.out.println("Key: " + pair.getKey() + ", Value: " + pair.getValue());
+ }
+}
diff --git a/OOPs/Generics/notes b/OOPs/Generics/notes
new file mode 100644
index 0000000..35de1a6
--- /dev/null
+++ b/OOPs/Generics/notes
@@ -0,0 +1,54 @@
+Generics
+=> allow you to code that is independent of a specific data type while ensuring type safety at compile time.
+
+#Key Benefits:
+- Type Safety
+- Eleimation of cast
+- Code Resuablity
+- Improved Readability
+
+
+Generics use type parameter (), to specify the type(s) of a class, interface or method.
+
+#Syntax:
+ public class GenericsClass {
+ private T Data;
+ public GenericClass(T data) {
+ this.data = data;
+ }
+ public T getdata() {
+ return data;
+ }
+ }
+
+ T => Type parameter and can be replaced by any type- "Integer, String" ..etc
+
+
+ *Type Parameter
+ a) T - type
+ b) E - Element
+ c) K - Key
+ d) V - Value
+ E) N - Number
+
+
+
+ #Bounded Type Parameters
+
+ => Bounded type parameter restrics the types that can be used with a generic class or method. you can use with the "extends" keyword to specify that the type must be a sub class of a specific class or implements specific interfaces.
+
+ Ex:
+ public class BoundedClass {
+ private T number:
+ public BoundedClass(T Number) {
+ this.number = number;
+ }
+ public class square() {
+ returns number.doublevalue() * number.doublevalue();
+ }
+ }
+
+ public static void main(String[] args) {
+ BoundedClass intObj = new BoundedClass(5);
+ System.out.println("Square" + intObj.square());
+ }
\ No newline at end of file
diff --git a/OOPs/Interfaces/Main.java b/OOPs/Interfaces/Main.java
new file mode 100644
index 0000000..2c22051
--- /dev/null
+++ b/OOPs/Interfaces/Main.java
@@ -0,0 +1,25 @@
+//defiing an interface
+interface Animal {
+ //abstract methods
+ void sound();
+ void eat();
+}
+//creating a class that implements the interface
+class Dog implements Animal{
+ @Override
+ public void sound(){
+ System.out.println("Dog barks");
+ }
+ @Override
+ public void eat(){
+ System.out.println("Dog eat bones");
+ }
+}
+
+public class Main{
+ public static void main(String[] args) {
+ Animal mydog = new Dog();
+ mydog.sound();
+ mydog.eat();
+ }
+}
\ No newline at end of file
diff --git a/OOPs/Interfaces/MyInter.java b/OOPs/Interfaces/MyInter.java
new file mode 100644
index 0000000..b171d82
--- /dev/null
+++ b/OOPs/Interfaces/MyInter.java
@@ -0,0 +1,40 @@
+// First Interface
+interface Printable{
+ void print();
+ // it is an abstract method by default
+}
+
+//Second Interface
+interface Showable{
+ void show();
+}
+
+//Third interface
+interface PhotoCopy{
+ void photo();
+}
+//Class implementing multiple interfaces
+class Document implements Printable, Showable, PhotoCopy{
+ @Override
+ public void print(){
+ System.out.println("Printing documents...");
+ }
+
+ @Override
+ public void show(){
+ System.out.println("Showing document...");
+ }
+ @Override
+ public void photo(){
+ System.out.println("Bhaiya ek photo copy dena");
+ }
+}
+
+public class MyInter{
+ public static void main(String[] args) {
+ Document mydoc = new Document();
+ mydoc.print();
+ mydoc.show();
+ mydoc.photo();
+ }
+}
\ No newline at end of file
diff --git a/OOPs/Interfaces/mini/MyBrake.java b/OOPs/Interfaces/mini/MyBrake.java
new file mode 100644
index 0000000..a5880ad
--- /dev/null
+++ b/OOPs/Interfaces/mini/MyBrake.java
@@ -0,0 +1,5 @@
+package mini;
+
+ public Interface MyBrake {
+ void brake();
+ }
diff --git a/OOPs/Interfaces/mini/MyCar.java b/OOPs/Interfaces/mini/MyCar.java
new file mode 100644
index 0000000..1ff6e6d
--- /dev/null
+++ b/OOPs/Interfaces/mini/MyCar.java
@@ -0,0 +1,21 @@
+package mini;
+
+ public Interface MyCar implements MyEngine, MyBrake {
+ @Override
+ public void brake() {
+ System.out.println("I brake like a normal car");
+ };
+ @Override
+ public void start() {
+ System.out.println("I start like a normal car");
+ }
+ @Override
+ public void stop() {
+ System.out.println("I stop like a normal car");
+ }
+ @Override
+ public void acc() {
+ System.out.println("I Acc. like a normal");
+ }
+
+ }
diff --git a/OOPs/Interfaces/mini/MyCdPlayer.java b/OOPs/Interfaces/mini/MyCdPlayer.java
new file mode 100644
index 0000000..a195648
--- /dev/null
+++ b/OOPs/Interfaces/mini/MyCdPlayer.java
@@ -0,0 +1,13 @@
+package mini;
+
+public Interface MyCdPlayer implements MyMedia {
+ @Override
+ public void start() {
+ System.out.println("music starts");
+ }
+ @Override
+ public void stop() {
+ System.out.println("music stop");
+ }
+
+}
diff --git a/OOPs/Interfaces/mini/MyEngine.java b/OOPs/Interfaces/mini/MyEngine.java
new file mode 100644
index 0000000..f040a23
--- /dev/null
+++ b/OOPs/Interfaces/mini/MyEngine.java
@@ -0,0 +1,8 @@
+package mini;
+
+public Interface MyEngine {
+ Static final PRICE = 7800;
+ void start();
+ void stop();
+ void acc();
+}
diff --git a/OOPs/Interfaces/mini/MyMain.java b/OOPs/Interfaces/mini/MyMain.java
new file mode 100644
index 0000000..c094c89
--- /dev/null
+++ b/OOPs/Interfaces/mini/MyMain.java
@@ -0,0 +1,14 @@
+package mini;
+
+import SelfQuestions.PublicPrivate.Car;
+
+public class MyMain {
+ public static void main(String[] args) {
+ Car myCar = new Car();
+ myCar.acc();
+ myCar.start();
+ myCar.stop();
+ }
+}
+
+// the major difference etween a class and interface is varibales in the interface are only static and final nothing else . while a java interface can be created using "impliment" keyword while java classes are created using "entends " keywords
diff --git a/OOPs/Interfaces/mini/MyMedia.java b/OOPs/Interfaces/mini/MyMedia.java
new file mode 100644
index 0000000..7b0d383
--- /dev/null
+++ b/OOPs/Interfaces/mini/MyMedia.java
@@ -0,0 +1,6 @@
+package mini;
+
+public Interface MyMedia {
+ void start();
+ void stop();
+}
diff --git a/OOPs/Interfaces/mini/MyPowerEngine.java b/OOPs/Interfaces/mini/MyPowerEngine.java
new file mode 100644
index 0000000..357755b
--- /dev/null
+++ b/OOPs/Interfaces/mini/MyPowerEngine.java
@@ -0,0 +1,16 @@
+package mini;
+
+public Interface MyPowerEngine implements MyEngine {
+ @Override
+ void starts() {
+ System.out.println("Power Engine Start");
+ }
+ @Override
+ void stop() {
+ System.out.println("Power Engine Stop");
+ }
+ @Override
+ void acc() {
+ System.out.println("Power engine acc.");
+ }
+}
diff --git a/OOPs/Interfaces/notes b/OOPs/Interfaces/notes
new file mode 100644
index 0000000..b65bf15
--- /dev/null
+++ b/OOPs/Interfaces/notes
@@ -0,0 +1,2 @@
+ Interfaces
+ -> An interface in a java is a reference type, similar to a class, that defines of methods class
\ No newline at end of file
diff --git a/OOPs/Interfaces/screenshot/1.jpg b/OOPs/Interfaces/screenshot/1.jpg
new file mode 100644
index 0000000..757986a
Binary files /dev/null and b/OOPs/Interfaces/screenshot/1.jpg differ
diff --git a/OOPs/Interfaces/screenshot/2.jpg b/OOPs/Interfaces/screenshot/2.jpg
new file mode 100644
index 0000000..343874f
Binary files /dev/null and b/OOPs/Interfaces/screenshot/2.jpg differ
diff --git a/OOPs/Interfaces/screenshot/3.jpg b/OOPs/Interfaces/screenshot/3.jpg
new file mode 100644
index 0000000..4c7c50d
Binary files /dev/null and b/OOPs/Interfaces/screenshot/3.jpg differ
diff --git a/OOPs/OOPs.iml b/OOPs/OOPs.iml
new file mode 100644
index 0000000..0bac05d
--- /dev/null
+++ b/OOPs/OOPs.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index e2a197c..bad3bbc 100644
--- a/README.md
+++ b/README.md
@@ -1,86 +1,694 @@
-# โ Java-Programs
+
-Hey there! ๐
-Welcome to my Java learning repo! This repository contains all the Java programs Iโm writing while learning the language โ from absolute basics to object-oriented programming and more. Whether you're learning with me or just looking for some simple Java examples, you're in the right place. ๐ป๐
+
This repository chronicles my 100-day journey mastering Java programming from absolute basics to advanced concepts. Every line of code represents dedication, growth, and the pursuit of becoming a skilled Software Development Engineer.
+
+
+
---
-๐ง Learning Path
-I'm learning Java as part of my Full Stack Development course at Groot Academy ๐จโ๐ป
-Also pursuing B.Tech (CSE) from GIT Jaipur ๐ซ
-Started with:
+## ๐ Next Steps
+
+
-C โ
-C++ โ
-HTML, CSS โ
-Now diving deep into Java ๐ฅ
+### ๐ฏ **Ready for the Next Challenge?**
+
+
+
+
+
+
+
+
+
+### ๐ **Advanced Java Journey Continues!**
+
+Having mastered the fundamentals, it's time to dive into enterprise-level Java development! The journey doesn't stop hereโit evolves.
+
+**What's Next:**
+- ๐ **Web Development** with Spring Framework
+- ๐๏ธ **Database Integration** with Hibernate & JPA
+- ๐ **RESTful APIs** and Microservices
+- ๐งช **Testing** with JUnit & Mockito
+- ๐๏ธ **Enterprise Patterns** and Architecture
+- โ๏ธ **Cloud Deployment** and DevOps
+
+
+
+
+### ๐ **Continue Learning**
+
+
+
+[](https://github.com/Piyush64-bit/AdvanceJava-Programs)
+
+
---
-๐ฌ Connect With Me
+## ๐ค For Learners
+
+
+
+### ๐ **This Repository is Perfect For:**
+
+
+
+
+
+
+
๐ Beginners
+Starting their Java journey from scratch
+
+Zero to Hero path
+
+
+
๐ Intermediate
+Reviewing and strengthening core concepts
+
+Skill reinforcement
+
+
+
๐ฏ Students
+Preparing for interviews or exams
+
+Academic excellence
+
+
+
๐จโ๐ป Self-learners
+Who prefer learning by example
+
+Hands-on approach
+
+
+
+
+
+
+
+
๐ How to Use This Repository:
+
+
+
+
+
-๐ LinkedIn โ @piyush64bit
-๐ผ Portfolio coming soon...
+### ๐ **Learning Path**
+1. **Start with Basics** - Follow numbered folders sequentially
+2. **Practice Along** - Don't just read, code along!
+3. **Modify & Experiment** - Change code and observe results
+4. **Challenge Yourself** - Solve problems before looking at solutions
-๐ค Feel free to fork, star โญ and open PRs or issues if you have suggestions!
+
+
+
+### ๐ **Contribution Guidelines**
+- ๐ **Found a bug?** Open an issue with details
+- ๐ก **Have a better solution?** Submit a pull request
+- ๐ **Want to add documentation?** We'd love that!
+- โญ **Found it helpful?** Give it a star!
+
+
+
+
---
-Made with โค๏ธ by Piyush | Born to Code โก
+## ๐ฌ Connect
+
+