├── InterfacesDemo ├── Brake.java ├── CDplayer.java ├── Car.java ├── ElectricEngine.java ├── Engine.java ├── Main.java ├── Media.java ├── NiceCar.java └── PowerEngine.java ├── Lecture1 ├── OOP1_Classes_And_Objects │ ├── Array_of_student.java │ └── Class_demo.java ├── OOP2_Constructors │ ├── Constructor_Overloading.java │ └── Demo_Constructor.java ├── OOP3_wrapper_classes │ └── WrapperDemo.java └── OOP4_final_keyword │ └── finalDemo.java ├── Lecture2 ├── Import_Keyword.java ├── Singleton_Class │ ├── Main.java │ └── SingleTon.java └── StaticExample │ ├── Human.java │ └── Main.java ├── Lecture3 └── Inheritance │ ├── Child.java │ ├── Main.java │ └── Parent.java └── Lecture4 ├── Animal.java ├── Dog.java ├── Main.java └── Puppies.java /InterfacesDemo/Brake.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public interface Brake { 4 | void brake(); 5 | } 6 | -------------------------------------------------------------------------------- /InterfacesDemo/CDplayer.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public class CDplayer implements Media { 4 | 5 | @Override 6 | public void start() { 7 | System.out.println("Music Start"); 8 | } 9 | 10 | @Override 11 | public void stop() { 12 | System.out.println("Music Stop"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /InterfacesDemo/Car.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public class Car implements Engine, Brake, Media { 4 | 5 | @Override 6 | public void brake() { 7 | System.out.println("I brake like a normal car"); 8 | } 9 | 10 | @Override 11 | public void start() { 12 | System.out.println("I start like a normal car"); 13 | } 14 | 15 | @Override 16 | public void stop() { 17 | System.out.println("I stop like a normal car"); 18 | } 19 | 20 | @Override 21 | public void accelerate() { 22 | System.out.println("I accelerate like a normal car"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /InterfacesDemo/ElectricEngine.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public class ElectricEngine implements Engine { 4 | @Override 5 | public void start() { 6 | System.out.println("Electric engine start"); 7 | } 8 | 9 | @Override 10 | public void stop() { 11 | 12 | System.out.println("Electric engine stop"); 13 | } 14 | 15 | @Override 16 | public void accelerate() { 17 | System.out.println("Electric engine accelerate"); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /InterfacesDemo/Engine.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public interface Engine { 4 | void start(); 5 | void stop(); 6 | void accelerate(); 7 | } 8 | -------------------------------------------------------------------------------- /InterfacesDemo/Main.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | import jdk.dynalink.NamedOperation; 4 | 5 | public class Main { 6 | public static void main(String[] args) { 7 | // Car car = new Car(); 8 | // car.start(); 9 | // car.accelerate(); 10 | // car.brake(); 11 | // car.stop(); 12 | NiceCar car = new NiceCar(new PowerEngine()); 13 | car.startEngine(); 14 | car.startMusic(); 15 | car.updateEngine(); 16 | car.stopEngine(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /InterfacesDemo/Media.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public interface Media { 4 | void start(); 5 | void stop(); 6 | } 7 | -------------------------------------------------------------------------------- /InterfacesDemo/NiceCar.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public class NiceCar { 4 | private Engine engine; 5 | private Media player = new CDplayer(); 6 | 7 | public NiceCar() { 8 | engine = new PowerEngine(); 9 | } 10 | 11 | public NiceCar(Engine engine) { 12 | this.engine = engine; 13 | } 14 | 15 | public void startEngine() { 16 | engine.start(); 17 | } 18 | 19 | public void stopEngine() { 20 | engine.stop(); 21 | } 22 | 23 | public void startMusic() { 24 | player.start(); 25 | } 26 | 27 | public void stopMusic() { 28 | player.stop(); 29 | } 30 | 31 | public void updateEngine(){ 32 | engine =new ElectricEngine(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /InterfacesDemo/PowerEngine.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.InterfacesDemo; 2 | 3 | public class PowerEngine implements Engine{ 4 | @Override 5 | public void start() { 6 | System.out.println("Power Engine Start"); 7 | } 8 | 9 | @Override 10 | public void stop() { 11 | System.out.println("Power Engine Stop"); 12 | 13 | } 14 | 15 | @Override 16 | public void accelerate() { 17 | System.out.println("Power Engine Accelerate"); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Lecture1/OOP1_Classes_And_Objects/Array_of_student.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture1.OOP1_Classes_And_Objects; 2 | 3 | import java.util.Arrays; 4 | 5 | public class Array_of_student { 6 | public static void main(String[] args) { 7 | Student1[] students = new Student1[5]; 8 | 9 | students[0] = new Student1(); 10 | students[1] = new Student1(); 11 | students[2] = new Student1(); 12 | students[3] = new Student1(); 13 | students[4] = new Student1(); 14 | 15 | students[0].name = "Ayush Soni"; 16 | students[1].name = "Khushi Soni"; 17 | students[2].name = "Vaibhavi Deshpande"; 18 | students[3].name = "Rutuja Chavan"; 19 | students[4].name = "Amardeep Pawar"; 20 | 21 | students[0].roll_No = 1; 22 | students[1].roll_No = 2; 23 | students[2].roll_No = 3; 24 | students[3].roll_No = 4; 25 | students[4].roll_No = 5; 26 | 27 | System.out.println(); 28 | System.out.println(); 29 | 30 | System.out.println(Arrays.toString(students)); 31 | 32 | // for (int i = 0; i < students.length; i++) { 33 | // System.out.println(students[i].roll_No + " " +students[i].name); 34 | // } 35 | } 36 | 37 | } 38 | 39 | class Student1 { 40 | int roll_No; 41 | String name ; 42 | } 43 | -------------------------------------------------------------------------------- /Lecture1/OOP1_Classes_And_Objects/Class_demo.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture1.OOP1_Classes_And_Objects; 2 | 3 | public class Class_demo { 4 | 5 | public static void main(String[] args) { 6 | 7 | Student s1 = new Student(); 8 | Student s2 = new Student(); 9 | Student s3 = new Student(); 10 | s1.name = "Ayush Soni"; 11 | s1.roll_no = 1; 12 | s2.name = "Khushi Soni"; 13 | s2.roll_no = 2; 14 | s3.name = "Kunal Kushwaha"; 15 | s3.roll_no = 3; 16 | 17 | System.out.println(s1.name); 18 | System.out.println(s2.name); 19 | System.out.println(s3.name); 20 | 21 | } 22 | 23 | 24 | } 25 | 26 | class Student { 27 | String name; 28 | int roll_no; 29 | } 30 | -------------------------------------------------------------------------------- /Lecture1/OOP2_Constructors/Constructor_Overloading.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture1.OOP2_Constructors; 2 | 3 | public class Constructor_Overloading { 4 | public static void main(String[] args) { 5 | // Students kunal = new Students(13,"Kunal", 98.76f); 6 | // 7 | // System.out.println(kunal.roll); 8 | // System.out.println(kunal.name); 9 | // System.out.println(kunal.marks); 10 | // 11 | // Students random = new Students(kunal); 12 | // 13 | // System.out.println(random.roll); 14 | // System.out.println(random.name); 15 | // System.out.println(random.marks); 16 | 17 | Students kush = new Students(); 18 | System.out.println(kush.roll); 19 | System.out.println(kush.marks); 20 | System.out.println(kush.name); 21 | } 22 | } 23 | 24 | class Students{ 25 | int roll; 26 | String name; 27 | float marks; 28 | 29 | Students(int roll, String name, float marks) { 30 | this.roll = roll; 31 | this.name = name; 32 | this.marks = marks; 33 | } 34 | 35 | Students(Students other) { 36 | this.roll = other.roll; 37 | this.name = other.name; 38 | this.marks = other.marks; 39 | } 40 | 41 | //calling constructor from another constructor 42 | Students(){ 43 | this(13,"Ayush",34.32f); 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Lecture1/OOP2_Constructors/Demo_Constructor.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture1.OOP2_Constructors; 2 | 3 | public class Demo_Constructor { 4 | 5 | 6 | public static void main(String[] args) { 7 | // here we are performing repetitive task 8 | // Student s1 = new Student(); 9 | // s1.marks = 24.23f; 10 | // s1.name = "Ayush Soni"; 11 | // s1.rollNo = 13; 12 | 13 | 14 | Student s1 = new Student(); 15 | Student s2 = new Student(13, "Khushi Soni"); 16 | Student s3 = new Student(11, "Ayush Soni", 34.56f); 17 | System.out.println(s2.name + " " + s2.rollNo); 18 | // System.out.println(s1.rollNo + " " + s1.marks + " " + s1.name); 19 | // System.out.println(s3); 20 | System.out.println(s3.rollNo + " " + s3.marks + " " + s3.name); 21 | } 22 | } 23 | 24 | class Student { 25 | int rollNo; 26 | String name; 27 | float marks; 28 | 29 | Student() { 30 | this.rollNo = 12; 31 | this.name = "Ayush Soni"; 32 | this.marks = 88.65f; 33 | } 34 | 35 | Student(int roll_num, String naam) { 36 | rollNo = roll_num; 37 | name = naam; 38 | 39 | } 40 | 41 | Student(int rollNo, String name, float marks) { 42 | this.rollNo = rollNo; 43 | this.name = name; 44 | this.marks = marks; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Lecture1/OOP3_wrapper_classes/WrapperDemo.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture1.OOP3_wrapper_classes; 2 | 3 | public class WrapperDemo { 4 | public static void main(String[] args) { 5 | Integer a= 34; 6 | Integer b= 134; 7 | System.out.println(a + " " + b); 8 | Integer c = a; 9 | System.out.println(c); 10 | System.out.println(a); 11 | swap(a,b); 12 | System.out.println(a + " " + b); 13 | } 14 | 15 | static void swap(Integer a, Integer b){ 16 | Integer temp = a; 17 | a = b; 18 | b = temp; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Lecture1/OOP4_final_keyword/finalDemo.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture1.OOP4_final_keyword; 2 | 3 | public class finalDemo { 4 | public static void main(String[] args) { 5 | // int a = 30; 6 | // final int b = 49; 7 | // a = 3459; 8 | //// b = 4534; // this gives compile time error 9 | // System.out.println(a + " " + b); 10 | final A a1 = new A("Ayush"); 11 | final A b1 = new A("Kunal"); 12 | final A c1 = new A("Vaibhavi"); 13 | System.out.println(a1.name); 14 | System.out.println(b1.name); 15 | System.out.println(c1.name); 16 | 17 | a1.name = "Somerthing"; 18 | System.out.println(a1.name); 19 | // a1 = b1; we can't do that as our object is made final 20 | } 21 | } 22 | 23 | class A { 24 | String name; 25 | 26 | A(String name) { 27 | this.name = name; 28 | } 29 | } -------------------------------------------------------------------------------- /Lecture2/Import_Keyword.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture2; 2 | import java.util.ArrayList; 3 | public class Import_Keyword { 4 | public static void main(String[] args) { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Lecture2/Singleton_Class/Main.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture2.Singleton_Class; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | SingleTon obj1 = SingleTon.getInstance(); 6 | SingleTon obj2 = SingleTon.getInstance(); 7 | SingleTon obj3 = SingleTon.getInstance(); 8 | SingleTon obj4 = SingleTon.getInstance(); 9 | 10 | 11 | System.out.println(obj1 == obj2); 12 | System.out.println(obj2 == obj3); 13 | System.out.println(obj3 == obj4); 14 | 15 | // A a = new A(); 16 | // A a1 = new A(); 17 | // A a2 = new A(); 18 | // System.out.println(a==a1); 19 | // System.out.println(a1==a2); 20 | } 21 | } 22 | //class A{ 23 | // A(){ 24 | // 25 | // } 26 | //} -------------------------------------------------------------------------------- /Lecture2/Singleton_Class/SingleTon.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture2.Singleton_Class; 2 | 3 | public class SingleTon { 4 | 5 | private SingleTon(){ 6 | 7 | } 8 | private static SingleTon instance; 9 | 10 | public static SingleTon getInstance(){ 11 | if (instance == null){ 12 | instance = new SingleTon(); 13 | } 14 | return instance; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Lecture2/StaticExample/Human.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture2.StaticExample; 2 | 3 | public class Human { 4 | static long population; 5 | int age; 6 | String name; 7 | int salary; 8 | Boolean married; 9 | 10 | public Human(int age, String name, int salary, Boolean married) { 11 | this.age = age; 12 | this.name = name; 13 | this.salary = salary; 14 | this.married = married; 15 | // this.population += 1; 16 | population += 1; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Lecture2/StaticExample/Main.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture2.StaticExample; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | 6 | Human ayush = new Human(22,"Ayush",40000,false); 7 | Human vaibhavi = new Human(22,"Vaibhavi",40000,false); 8 | Human khushi = new Human(18,"Khushi",10000,false); 9 | 10 | System.out.println(ayush.age); 11 | System.out.println(vaibhavi.salary); 12 | 13 | System.out.println(ayush.population); 14 | System.out.println(vaibhavi.population); 15 | 16 | System.out.println(Human.population); 17 | System.out.println(Human.population); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Lecture3/Inheritance/Child.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture3.Inheritance; 2 | 3 | class Child extends Parent{ 4 | int age; 5 | 6 | Child(){ 7 | this.age = -1; 8 | } 9 | 10 | public Child(int l, int b, int h, int age) { 11 | // this.l = l; 12 | // this.b = b; 13 | // this.h = h; 14 | super(l,b,h); // calling the parent class constructor 15 | this.age = age; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Lecture3/Inheritance/Main.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture3.Inheritance; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | // Parent p1 = new Parent(); 6 | // Parent p2 = new Parent(12,23,45); 7 | // Parent p3 = new Parent(p2); 8 | // Parent p4 = new Parent(34); 9 | // 10 | // System.out.println(p1.l + " " + p1.b + " " + p1.h); 11 | // System.out.println(p2.l + " " + p2.b + " " + p2.h); 12 | // System.out.println(p3.l + " " + p3.b + " " + p3.h); 13 | // System.out.println(p4.l + " " + p4.b + " " + p4.h); 14 | 15 | Child c1 = new Child(); 16 | Child c2 = new Child(12,23,34,1); 17 | System.out.println(c1.age + " " + c1.l + " " + c1.b + " " + c1.h); 18 | System.out.println(c2.age + " " + c2.l + " " + c2.b + " " + c2.h); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Lecture3/Inheritance/Parent.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture3.Inheritance; 2 | 3 | public class Parent { 4 | int l; 5 | int b; 6 | int h; 7 | 8 | Parent() { 9 | this.l = -1; 10 | this.b = -1; 11 | this.h = -1; 12 | } 13 | 14 | Parent(int size) { 15 | this.l = size; 16 | this.b = size; 17 | this.h = size; 18 | } 19 | 20 | Parent(Parent other) { 21 | this.l = other.l; 22 | this.b = other.b; 23 | this.h = other.h; 24 | } 25 | 26 | Parent(int l, int b, int h) { 27 | this.l = l; 28 | this.b = b; 29 | this.h = h; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Lecture4/Animal.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture4; 2 | 3 | public class Animal { 4 | private int legs; 5 | int tail; 6 | String name; 7 | 8 | public Animal(int legs, int tail, String name) { 9 | this.legs = legs; 10 | this.tail = tail; 11 | this.name = name; 12 | } 13 | 14 | public Animal(int legs) { 15 | this.legs = legs; 16 | 17 | } 18 | 19 | public Animal(Animal animal) { 20 | this.legs = animal.legs; 21 | this.tail = animal.tail; 22 | this.name = animal.name; 23 | } 24 | 25 | void walk() { 26 | System.out.println(" Animal is walking"); 27 | } 28 | 29 | void walk(int legs) { 30 | System.out.println(" Animal is walking on " + legs + " legs "); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Lecture4/Dog.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture4; 2 | 3 | public class Dog extends Animal { 4 | 5 | int weight; 6 | 7 | public Dog(int legs, int tail, String name, int weight) { 8 | super(legs, tail, name); 9 | this.weight = weight; 10 | } 11 | 12 | 13 | public Dog(int legs, int tail, String name) { 14 | super(legs, tail, name); 15 | } 16 | 17 | void bark(){ 18 | System.out.println(" Dogs Barks "); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Lecture4/Main.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture4; 2 | 3 | public class Main { 4 | public static void main(String[] args) { 5 | // Animal animal = new Animal(4, 1, "Cat"); 6 | // System.out.println( animal.legs); 7 | // Animal animal1 = new Dog(4, 1, "Cat"); 8 | // Dog d1 = new Dog(4,1,"Muku"); 9 | // Dog d = new Animal(4,1,"Dog"); // this gives an error 10 | Puppies d = new Puppies(4,1,"Shriro"); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Lecture4/Puppies.java: -------------------------------------------------------------------------------- 1 | package OOPS_By_KK.Lecture4; 2 | 3 | public class Puppies extends Dog{ 4 | int cuteNess; 5 | 6 | public Puppies(int legs, int tail, String name, int weight, int cuteNess) { 7 | super(legs, tail, name, weight); 8 | this.cuteNess = cuteNess; 9 | } 10 | 11 | public Puppies(int legs, int tail, String name) { 12 | super(legs, tail, name); 13 | } 14 | 15 | void play(){ 16 | System.out.println(" Puppies are playing "); 17 | } 18 | } 19 | --------------------------------------------------------------------------------