├── .gitignore
├── .idea
├── .gitignore
├── misc.xml
├── modules.xml
├── uiDesigner.xml
└── vcs.xml
├── LearningATB7xJavaPrograms.iml
├── README.md
└── src
├── aug
├── ex_04082024
│ ├── ATBPerson.java
│ ├── BankAccount.java
│ ├── Car.java
│ ├── FatherElon.java
│ ├── Lab162.java
│ ├── Lab163.java
│ ├── Lab164.java
│ ├── Lab165.java
│ ├── Lab166.java
│ ├── Lab167.java
│ ├── Lab168.java
│ ├── Lab169.java
│ ├── Lab170.java
│ ├── Lab171.java
│ ├── Lab173.java
│ ├── Lab177.java
│ ├── Person.java
│ ├── accessModifiers
│ │ ├── Lab176.java
│ │ ├── criminal
│ │ │ └── Thief.java
│ │ └── police
│ │ │ ├── Cop.java
│ │ │ ├── JrCop.java
│ │ │ └── Pramod.java
│ ├── hasA
│ │ ├── ex
│ │ │ ├── Car.java
│ │ │ ├── Engine.java
│ │ │ └── Tyres.java
│ │ └── isA
│ │ │ └── Tesla.java
│ ├── hierachicalinheritance
│ │ ├── Father.java
│ │ ├── Lab175.java
│ │ ├── Lucky.java
│ │ ├── Pramod.java
│ │ └── Ruhani.java
│ ├── multilevelinheritance
│ │ ├── Child.java
│ │ ├── Father.java
│ │ ├── GrandFather.java
│ │ └── Lab174.java
│ ├── multipleinheritance
│ │ ├── Child.java
│ │ ├── Father.java
│ │ ├── Lab176.java
│ │ └── Mother.java
│ ├── p1
│ │ └── Car.java
│ ├── p2
│ │ └── Car.java
│ ├── realTime
│ │ └── Lab176.java
│ └── singleheritance
│ │ ├── Father.java
│ │ ├── Lab172.java
│ │ ├── Son.java
│ │ ├── ex
│ │ ├── Programming.java
│ │ └── Python.java
│ │ └── real
│ │ ├── BaseTest.java
│ │ ├── GrandBaseTest.java
│ │ ├── TestCase.java
│ │ └── TestCase2.java
├── ex_10082024
│ ├── RealTimeInheritance.java
│ ├── ecap
│ │ ├── ICICIBank.java
│ │ ├── Lab178.java
│ │ ├── Lab179.java
│ │ ├── Lab180.java
│ │ └── VWOLoginPage.java
│ ├── poly
│ │ ├── methodoveridding
│ │ │ ├── Dog.java
│ │ │ ├── Hound.java
│ │ │ └── Lab182.java
│ │ └── methodoverloading
│ │ │ ├── Lab181.java
│ │ │ └── MathOperations.java
│ └── superthiskeyword
│ │ ├── Lab183.java
│ │ ├── Lab184.java
│ │ └── Lab185.java
├── ex_11082024
│ ├── Lab186.java
│ ├── Lab207.java
│ ├── RealLIFEex
│ │ ├── BaseClass.java
│ │ ├── CHOMRE.java
│ │ ├── FIREFOX.java
│ │ ├── GrandBaseClass.java
│ │ └── Lab189.java
│ ├── exLoan
│ │ ├── Father.java
│ │ ├── Lab188.java
│ │ └── Son.java
│ ├── ex_interface
│ │ ├── Engine.java
│ │ ├── Lab190.java
│ │ ├── Lab191.java
│ │ ├── WagonR.java
│ │ ├── ex2
│ │ │ ├── CarC.java
│ │ │ ├── E.java
│ │ │ └── PramodA.java
│ │ ├── ex3
│ │ │ └── Lab192.java
│ │ └── multipleinheritnace
│ │ │ ├── Father.java
│ │ │ ├── Lab192.java
│ │ │ ├── Mother.java
│ │ │ └── Son.java
│ ├── excar
│ │ ├── Car.java
│ │ ├── Engine.java
│ │ ├── GearBox.java
│ │ ├── Keys.java
│ │ ├── Lab187.java
│ │ ├── Tesla.java
│ │ ├── WagonR.java
│ │ └── i10.java
│ └── staticKeywrod
│ │ ├── Lab193.java
│ │ └── Lab194.java
├── ex_17082024
│ ├── APIConstants.java
│ ├── BUG.java
│ ├── COLORS.java
│ ├── Lab195.java
│ ├── Lab196.java
│ ├── Lab197.java
│ ├── Lab198.java
│ ├── Lab199.java
│ ├── Lab200.java
│ ├── Lab201.java
│ ├── Lab202.java
│ ├── Lab203.java
│ ├── Lab205.java
│ ├── Lab206.java
│ ├── Lab208.java
│ ├── Lab209.java
│ ├── Lab210.java
│ ├── Lab211.java
│ ├── Lab212.java
│ ├── Lab213.java
│ ├── Lab214.java
│ ├── Lab215.java
│ ├── Lab216.java
│ ├── Lab217.java
│ └── PAGES.java
├── ex_18082024
│ ├── Bank.java
│ ├── CollectionFramework
│ │ ├── Lab227.java
│ │ ├── Lab228.java
│ │ ├── Lab229.java
│ │ ├── Lab230.java
│ │ ├── Lab231.java
│ │ ├── Lab232.java
│ │ ├── Lab233.java
│ │ ├── Lab234.java
│ │ └── Lab235.java
│ ├── Lab218.java
│ ├── Lab219.java
│ ├── Lab220.java
│ ├── Lab221.java
│ ├── Lab222.java
│ ├── Lab223.java
│ ├── Lab224.java
│ ├── Lab225.java
│ └── Lab226.java
└── ex_24082024
│ ├── Lab236.java
│ ├── Lab237.java
│ ├── Lab238.java
│ ├── Lab239.java
│ ├── Lab240.java
│ ├── Lab241.java
│ ├── Lab242.java
│ ├── Lab243.java
│ ├── Lab244.java
│ ├── Lab245.java
│ ├── Lab246.java
│ ├── Lab247.java
│ ├── Lab248.java
│ └── Lab249.java
├── july
├── ex_07072024
│ ├── $Lab010.java
│ ├── Lab001.java
│ ├── Lab002.java
│ ├── Lab003.java
│ ├── Lab004.java
│ ├── Lab005.java
│ ├── Lab006.java
│ ├── Lab007.java
│ ├── Lab008.java
│ ├── Lab011.java
│ ├── Lab012.java
│ ├── Lab013.java
│ ├── Lab014.java
│ ├── Pramod123.java
│ ├── Pramod_Dutta.java
│ └── _Lab009.java
├── ex_13072024
│ ├── Lab015.java
│ ├── Lab016.java
│ ├── Lab017.java
│ ├── Lab018.java
│ ├── Lab019.java
│ ├── Lab020.java
│ ├── Lab021.java
│ ├── Lab022.java
│ ├── Lab023.java
│ ├── Lab024.java
│ ├── Lab025.java
│ ├── Lab026.java
│ ├── Lab027.java
│ ├── Lab028.java
│ ├── Lab029.java
│ ├── Lab030.java
│ ├── Lab031.java
│ ├── Lab032.java
│ ├── Lab033.java
│ ├── Lab034.java
│ ├── Lab035.java
│ ├── Lab036.java
│ ├── Lab037.java
│ ├── Lab038.java
│ ├── Lab039.java
│ ├── Lab040.java
│ ├── Lab041.java
│ ├── Lab042.java
│ ├── Lab043.java
│ ├── Lab044.java
│ ├── Lab045.java
│ ├── Lab046.java
│ ├── Lab047.java
│ ├── Lab048.java
│ └── Lab049.java
├── ex_14072024
│ ├── Lab050.java
│ ├── Lab051.java
│ ├── Lab052.java
│ ├── Lab053.java
│ ├── Lab054.java
│ ├── Lab055.java
│ ├── Lab056.java
│ ├── Lab057.java
│ ├── Lab058.java
│ ├── Lab059.java
│ ├── Lab060.java
│ ├── Lab061.java
│ ├── Lab062.java
│ ├── Lab063.java
│ ├── Lab064.java
│ ├── Lab065.java
│ ├── Lab066.java
│ ├── Lab067.java
│ ├── Lab068.java
│ ├── Lab069.java
│ ├── Lab070.java
│ ├── Lab071.java
│ ├── Lab072.java
│ ├── Lab073.java
│ ├── Lab074.java
│ ├── Lab075.java
│ ├── Lab076.java
│ ├── Lab077.java
│ ├── Lab078.java
│ ├── Lab079.java
│ ├── Lab080.java
│ └── Lab081.java
├── ex_20072024
│ ├── Lab082.java
│ ├── Lab083.java
│ ├── Lab084.java
│ ├── Lab085.java
│ ├── Lab086.java
│ ├── Lab087.java
│ ├── Lab088.java
│ ├── Lab089.java
│ ├── Lab090.java
│ ├── Lab091.java
│ ├── Lab092.java
│ ├── Lab093.java
│ ├── Lab094.java
│ ├── Lab095.java
│ ├── Lab096.java
│ ├── Lab097.java
│ ├── Lab098.java
│ ├── Lab099.java
│ ├── Lab100.java
│ ├── Lab101.java
│ ├── Lab102.java
│ ├── Lab103.java
│ ├── Lab104.java
│ └── Lab105.java
├── ex_21072024
│ ├── Lab106.java
│ ├── Lab107.java
│ ├── Lab108.java
│ ├── Lab109.java
│ ├── Lab110.java
│ ├── Lab111.java
│ ├── Lab112.java
│ ├── Lab113.java
│ ├── Lab114.java
│ ├── Lab115.java
│ ├── Lab116.java
│ ├── Lab117.java
│ ├── Lab118.java
│ ├── Lab119.java
│ ├── Lab120.java
│ ├── Lab121.java
│ ├── Lab122.java
│ ├── Lab123.java
│ ├── Lab124.java
│ ├── Lab125.java
│ ├── Lab126.java
│ ├── Lab127.java
│ ├── Lab128.java
│ ├── Lab129.java
│ ├── Lab130.java
│ ├── Lab131.java
│ ├── Lab132.java
│ ├── Lab133.java
│ ├── Lab134.java
│ ├── Lab135.java
│ └── Lab136.java
├── ex_27072024
│ ├── Lab137.java
│ ├── Lab138.java
│ ├── Lab139.java
│ ├── Lab140.java
│ ├── Lab141.java
│ ├── Lab142.java
│ ├── Lab143.java
│ ├── Lab144.java
│ ├── Lab145.java
│ ├── Lab146.java
│ ├── Lab147.java
│ ├── Lab148.java
│ ├── Lab149.java
│ ├── Lab150.java
│ ├── Lab151.java
│ ├── Lab152.java
│ └── Lab153.java
└── ex_28072024
│ ├── Animal.java
│ ├── Bank.java
│ ├── BuildingBP.java
│ ├── Car.java
│ ├── Dog.java
│ ├── Lab154.java
│ ├── Lab155.java
│ ├── Lab156.java
│ ├── Lab157.java
│ ├── Lab158.java
│ ├── Lab159.java
│ ├── Lab160.java
│ ├── Lab161.java
│ └── Person.java
└── postman_collections
├── PreProd Env.postman_environment.json
├── QA Env.postman_environment.json
├── REST API Project#2 - Restful Booker.postman_collection.json
└── integration_test
├── Project#1 - Restful Booker Integration Scenarios.postman_collection.json
└── QA Env.postman_environment.json
/.gitignore:
--------------------------------------------------------------------------------
1 | ### IntelliJ IDEA ###
2 | out/
3 | !**/src/main/**/out/
4 | !**/src/test/**/out/
5 |
6 | ### Eclipse ###
7 | .apt_generated
8 | .classpath
9 | .factorypath
10 | .project
11 | .settings
12 | .springBeans
13 | .sts4-cache
14 | bin/
15 | !**/src/main/**/bin/
16 | !**/src/test/**/bin/
17 |
18 | ### NetBeans ###
19 | /nbproject/private/
20 | /nbbuild/
21 | /dist/
22 | /nbdist/
23 | /.nb-gradle/
24 |
25 | ### VS Code ###
26 | .vscode/
27 |
28 | ### Mac OS ###
29 | .DS_Store
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LearningATB7xJavaPrograms.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Java Programs
2 |
3 | Author - Pramod
4 |
5 | This Repo contains the source code for the
6 | Exercise that we have done in the ATB7x batch
7 |
8 | - Core JAVA
9 | - OOPs
10 | - Collections Framework
11 | - Multi Threading
12 | - Design Patterns
13 | - FILE IO
14 | - Other misc concepts
15 | - Exception
16 |
17 |
18 | [Core Java.pdf](https://github.com/user-attachments/files/16118466/Core.Java.pdf)
19 |
20 |
21 | [[Java Notes] - TheTestingAcademy (Pramod Sir) (1).pdf](https://github.com/user-attachments/files/16118469/Java.Notes.-.TheTestingAcademy.Pramod.Sir.1.pdf)
22 |
23 |
24 |
25 | Postman Collection Also Added
26 |
27 |
28 | 
29 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/ATBPerson.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class ATBPerson {
4 |
5 | String name;
6 | long phone;
7 |
8 | // DC
9 | ATBPerson() {
10 | System.out.println("Object is created!");
11 | }
12 |
13 | ATBPerson(String nameGiven){
14 | this.name = nameGiven;
15 | // This current class.
16 | }
17 |
18 | ATBPerson(String nameGiven,long phoneNumber){
19 | this.name = nameGiven;
20 | this.phone = phoneNumber;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/BankAccount.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class BankAccount {
4 | String bankName;
5 | int balance;
6 | String bankCode; // Instance
7 |
8 | // DC
9 | BankAccount(){
10 | bankName = "SBI";
11 | balance = 0;
12 | bankCode = "SBI001";
13 | }
14 |
15 | // PC - 3 Argument
16 | BankAccount(String bName,int bal, String bCode){
17 | this.bankName = bName;
18 | this.balance = bal;
19 | this.bankCode = bCode;
20 | }
21 |
22 | BankAccount(String bName,int bal){
23 | this.bankName = bName;
24 | this.balance = bal;
25 |
26 | }
27 |
28 | BankAccount(String bName){
29 | this.bankName = bName;
30 | }
31 |
32 |
33 | void printDetails(){
34 | System.out.println("Bank Name -> " + bankName);
35 | System.out.println("Bank Code -> " + bankCode);
36 | System.out.println("Bal ->" + balance);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Car.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Car {
4 |
5 | // DC
6 | Car() {
7 | System.out.println("Starting");
8 |
9 | }
10 | void Dog(){
11 |
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/FatherElon.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class FatherElon {
4 | class Son1{
5 | class Son2{
6 |
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab162.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | import java.util.Scanner;
4 |
5 | public class Lab162 {
6 | public static void main(String[] args) {
7 | // Constructors
8 | // 1. default - 70%
9 | // 2. Parameters - 25%
10 | // 3. Copy Constructors - ~ 1-4%
11 | // this vs super - why? they are used?
12 | // Static keyword and static methods
13 |
14 |
15 | // Constructors
16 | // 1. default - 70%
17 | // 2. Parameters - 25%
18 | // 3. Copy Constructors - ~ 1-4%
19 |
20 |
21 |
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab163.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab163 {
4 | public static void main(String[] args) {
5 | Person p1 = new Person();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab164.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab164 {
4 | public static void main(String[] args) {
5 | Car c1 = new Car();
6 | // ClassName objectRef = new keyword + ClassName();
7 | new Car();
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab165.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab165 {
4 |
5 | int e= 45; // Instance Variable != Global Variable
6 |
7 | void f1(){
8 | int e = 10; // Local Variable
9 | System.out.println(e);
10 | }
11 |
12 | void f2(){
13 | e = 50;
14 | System.out.println(e);
15 | }
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab166.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab166 {
4 | String name;
5 |
6 | void talk(){}
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab167.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab167 {
4 | public static void main(String[] args) {
5 | Lab166 a = new Lab166();
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab168.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab168 {
4 | public static void main(String[] args) {
5 | ATBPerson p1 = new ATBPerson();
6 | new ATBPerson();
7 | new ATBPerson();
8 | ATBPerson p2 = null;
9 | //ATBPerson();
10 |
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab169.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab169 {
4 | public static void main(String[] args) {
5 | ATBPerson p0 = new ATBPerson();
6 | ATBPerson p1 = new ATBPerson("Pramod");
7 | ATBPerson p2 = new ATBPerson("Amit");
8 | ATBPerson p3 = new ATBPerson("Praveen",976543210);
9 | System.out.println(p0.name);
10 | System.out.println(p1.name);
11 | System.out.println(p2.phone);
12 |
13 |
14 |
15 | System.out.println(p3.name);
16 | System.out.println(p3.phone);
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab170.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | import july.ex_28072024.Bank;
4 |
5 | import java.util.Scanner;
6 |
7 | public class Lab170 {
8 | public static void main(String[] args) {
9 | BankAccount ba1 = new BankAccount();
10 |
11 | Scanner sc = new Scanner(System.in);
12 | System.out.println("Enter your Name of the Bank!");
13 | String bName = sc.next();
14 | System.out.println("Enter your Name of the Bal!");
15 | int bal = sc.nextInt();
16 | System.out.println("Enter your Name of the Bank cODE!");
17 |
18 | String bCode = sc.next();
19 |
20 | BankAccount baicici = new BankAccount(bName, bal, bCode);
21 |
22 |
23 | baicici.printDetails();
24 |
25 | sc.close();
26 |
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab171.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab171 {
4 |
5 | // Objects are real entity - runtime entrites
6 |
7 | // Every Object will be different
8 | // Class - Name, age
9 | // DC -> WHO WILL initialize the value of the name or age?
10 | // Class loader - null, 0
11 |
12 | // Constructors - DC - hardcode the value
13 | // PC -> We can ask the user what you want to initialize.
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab173.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | import aug.ex_04082024.p2.Car;
4 |
5 | public class Lab173 {
6 | public static void main(String[] args) {
7 | Car c1 = new Car();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Lab177.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Lab177 {
4 |
5 | class Pramod{
6 | class Lucky{
7 | class AMit{
8 | class Shardha{
9 |
10 | }
11 | }
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/Person.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024;
2 |
3 | public class Person {
4 | String name;
5 |
6 | // Special method
7 | Person(){
8 | System.out.println("Hi, I will be called, Object is created!");
9 | }
10 |
11 |
12 | void talk(){
13 | System.out.println("I am talking");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/accessModifiers/Lab176.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.accessModifiers;
2 |
3 | // Non sub class
4 | public class Lab176 {
5 | // public
6 | // private
7 | // protected
8 | // default - nothing
9 |
10 | public static void main(String[] args) {
11 |
12 | }
13 |
14 | }
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/accessModifiers/criminal/Thief.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.accessModifiers.criminal;
2 |
3 | import aug.ex_04082024.accessModifiers.police.Cop;
4 |
5 | public class Thief {
6 | public static void main(String[] args) {
7 | Cop c = new Cop(100);
8 | //System.out.println(c.gun);
9 | //c.canIShoot();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/accessModifiers/police/Cop.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.accessModifiers.police;
2 |
3 | public class Cop {
4 | private int gun;
5 | private String idCard;
6 |
7 | public Cop(int gun){
8 | this.gun = gun;
9 | }
10 | protected void canIShoot(){
11 | System.out.println("Yes, You can!!");
12 | }
13 | // protected = default - minor -
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/accessModifiers/police/JrCop.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.accessModifiers.police;
2 |
3 | public class JrCop {
4 | public static void main(String[] args) {
5 | Cop cop = new Cop(10);
6 | cop.canIShoot();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/accessModifiers/police/Pramod.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.accessModifiers.police;
2 |
3 | public class Pramod {
4 | private String name;
5 | private int id;
6 | // Instance should be well protected.
7 |
8 | private void talk(){} //
9 | // only class within the same pacakage can see us
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hasA/ex/Car.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hasA.ex;
2 |
3 | public class Car {
4 | // Aggregation - hasA
5 | protected void StartTheCar(){
6 | new Engine().start();
7 | new Tyres().rolling();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hasA/ex/Engine.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hasA.ex;
2 |
3 | public class Engine {
4 | void start(){
5 | System.out.println("Starting engine");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hasA/ex/Tyres.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hasA.ex;
2 |
3 | public class Tyres {
4 | void rolling(){
5 | System.out.println("Rolling Types");
6 | }
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hasA/isA/Tesla.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hasA.isA;
2 |
3 | import aug.ex_04082024.hasA.ex.Car;
4 | // isA -
5 | public class Tesla extends Car {
6 | void start(){
7 | StartTheCar();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hierachicalinheritance/Father.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hierachicalinheritance;
2 |
3 | public class Father {
4 | void home(){
5 | System.out.println("3BHK");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hierachicalinheritance/Lab175.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hierachicalinheritance;
2 |
3 | public class Lab175 {
4 | public static void main(String[] args) {
5 | Ruhani r = new Ruhani();
6 | r.home();
7 | r.r1();
8 |
9 | Pramod pramod = new Pramod();
10 | pramod.home();
11 |
12 | pramod.h2();
13 |
14 | Lucky l = new Lucky();
15 | l.l2();
16 | l.home();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hierachicalinheritance/Lucky.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hierachicalinheritance;
2 |
3 | public class Lucky extends Father {
4 | void l2(){
5 | System.out.println("Lucky");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hierachicalinheritance/Pramod.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hierachicalinheritance;
2 |
3 | public class Pramod extends Father{
4 |
5 | void h2(){
6 | System.out.println("h2 - Pramod");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/hierachicalinheritance/Ruhani.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.hierachicalinheritance;
2 |
3 | public class Ruhani extends Father{
4 | void r1(){
5 | System.out.println("ruhani");
6 | }
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multilevelinheritance/Child.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multilevelinheritance;
2 |
3 | public class Child extends Father{
4 | void home(){
5 | System.out.println("3BHK");
6 | }
7 |
8 | void c(){
9 | System.out.println("C");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multilevelinheritance/Father.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multilevelinheritance;
2 |
3 | public class Father extends GrandFather{
4 |
5 | void home(){
6 | System.out.println("2BHK");
7 |
8 | }
9 | void extra(){
10 | System.out.println("Extra");
11 | }
12 | void f(){
13 | System.out.println("F");
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multilevelinheritance/GrandFather.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multilevelinheritance;
2 |
3 | public class GrandFather {
4 | void home(){
5 | System.out.println("1BHK");
6 | }
7 |
8 | void gf(){
9 | System.out.println("GF");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multilevelinheritance/Lab174.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multilevelinheritance;
2 |
3 | public class Lab174 {
4 | public static void main(String[] args) {
5 | // Multi Level
6 | // GF -> F -> Child
7 | Child c1 = new Child();
8 | c1.home(); // If name is same C -> F -> GF
9 | c1.c();
10 | c1.gf();
11 | c1.f();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multipleinheritance/Child.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multipleinheritance;
2 |
3 | public class Child //extends Father,Mother
4 | {
5 | void C(){
6 | // home();
7 | // money();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multipleinheritance/Father.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multipleinheritance;
2 |
3 | public class Father {
4 | void home(){
5 | System.out.println("3BHK");
6 | }
7 | void money(){
8 | System.out.println("1 CR");
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multipleinheritance/Lab176.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multipleinheritance;
2 |
3 | public class Lab176 {
4 | // You get something from both the parents
5 | public static void main(String[] args) {
6 | Child c = new Child();
7 | //c.home();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/multipleinheritance/Mother.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.multipleinheritance;
2 |
3 | public class Mother {
4 | void home(){
5 | System.out.println("2BHK");
6 | }
7 | void money(){
8 | System.out.println("1.5 CR");
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/p1/Car.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.p1;
2 |
3 | public class Car {
4 | public Car(){
5 | System.out.println("Hello");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/p2/Car.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.p2;
2 |
3 | public class Car {
4 | public Car(){
5 | System.out.println("Hello");
6 | }
7 | }
--------------------------------------------------------------------------------
/src/aug/ex_04082024/realTime/Lab176.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.realTime;
2 |
3 | public class Lab176 {
4 | // Bank , ICICI -> store information
5 | // Bank and ICICI -> is A- icici - bank - extends 0 inheritance
6 | // Bank has customers - hasA
7 |
8 | // Programming Python,Java, -> ISa
9 |
10 |
11 | // Laptop, keyborad, mouse, camera -> HasA
12 |
13 | // isA or HasA -> Aggrestio
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/Father.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance;
2 |
3 | public class Father // Super Class
4 | {
5 | void bhk2(){
6 | System.out.println("2BHK");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/Lab172.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance;
2 |
3 | public class Lab172 {
4 | public static void main(String[] args) {
5 | Son s = new Son();
6 | s.bhk3();
7 | s.bhk2();
8 |
9 | Father f1 = new Father();
10 | f1.bhk2();
11 |
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/Son.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance;
2 |
3 | // Sub Class
4 | public class Son extends Father{
5 | // IS A - RELATIONSHIP
6 |
7 | void bhk3() {
8 | System.out.println("3BHK");
9 | //son can use father's surname but father cannot use son surname
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/ex/Programming.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance.ex;
2 |
3 | public class Programming {
4 | int version;
5 | String author;
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/ex/Python.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance.ex;
2 |
3 | public class Python extends Programming{
4 | // DC
5 | Python(){
6 | System.out.println("DC Python");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/real/BaseTest.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance.real;
2 |
3 | public class BaseTest extends GrandBaseTest{
4 |
5 | void startBrowser(){
6 | System.out.println("Staring Browser!!");
7 | }
8 |
9 | void closeBrowser(){
10 | System.out.println("Closing Browser!!");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/real/GrandBaseTest.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance.real;
2 |
3 | public class GrandBaseTest {
4 | int gold = 3;
5 | void getDataFromSQL(){
6 | System.out.println("MYSQL Connected");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/real/TestCase.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance.real;
2 |
3 | public class TestCase extends BaseTest{
4 |
5 | void testCase(){
6 | startBrowser();
7 | // Here we will write the TC
8 | closeBrowser();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/aug/ex_04082024/singleheritance/real/TestCase2.java:
--------------------------------------------------------------------------------
1 | package aug.ex_04082024.singleheritance.real;
2 |
3 | public class TestCase2 extends BaseTest{
4 |
5 | void testCase2(){
6 | startBrowser();// BaseTest
7 | getDataFromSQL(); // GrandBaseTest
8 | System.out.println(gold); // GrandBaseTest
9 | // Here we will write the TC
10 | closeBrowser();
11 | }
12 |
13 | public static void main(String[] args) {
14 | new TestCase2().testCase2();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/RealTimeInheritance.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024;
2 |
3 | public class RealTimeInheritance {
4 | public static void main(String[] args) {
5 | BaseClass t1 = new TestCase1(); // Dynamic Dispatch // Runtime
6 | //t1.setBrowser("opera",true);
7 | t1.openBrowser();
8 | t1.closeBrowser();
9 |
10 | }
11 | }
12 |
13 |
14 | class TestCase1 extends BaseClass{
15 | // TestCase is A Type of BaseCalss - Single Inheritance
16 | TestCase1(){
17 | super(); // DC of Parent
18 | this.setBrowser("edge",true);
19 | }
20 |
21 | @Override
22 | public void setBrowser(String browser, boolean isAuth) {
23 | super.setBrowser(browser, isAuth);
24 | }
25 | }
26 |
27 | class BaseClass{
28 | BaseClass(){
29 | System.out.println("DC - BaseClass");
30 | }
31 | BaseClass(String b){
32 | System.out.println("CC - BaseClass");
33 | }
34 |
35 | private String browser;
36 |
37 | public String getBrowser() {
38 | return browser;
39 | }
40 |
41 | public void setBrowser(String browser, boolean isAuth) {
42 | if (isAuth) {
43 | this.browser = browser;
44 | }else{
45 | System.out.println("Not Allowed");
46 | }
47 | }
48 |
49 |
50 | void openBrowser() {
51 | System.out.println("Chrome Browser!!");
52 | }
53 |
54 | void openBrowser(String browserName) {
55 | System.out.println("Open Browser!! -> " + browserName);
56 | }
57 | void closeBrowser() {
58 | System.out.println("Close Browser!!");
59 | }
60 |
61 | }
--------------------------------------------------------------------------------
/src/aug/ex_10082024/ecap/ICICIBank.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.ecap;
2 |
3 | public class ICICIBank {
4 |
5 | //## Encapsulation
6 | //- Encapsulation is a fundamental concept in object-oriented programming (OOP).
7 | //- Bundling of data and methods that operate on that data within a single unit.
8 | //- Data members should be private in nature.
9 | //- Methods with getter and setter only, you can access the data members / attributes.
10 |
11 | private String name;
12 | private long bal;
13 |
14 | public ICICIBank(String name, long bal) {
15 | this.name = name;
16 | this.bal = bal;
17 | }
18 |
19 | public long getBal(boolean isAdmin) {
20 | if (isAdmin) {
21 | return bal;
22 | } else {
23 | return 0;
24 | }
25 | }
26 |
27 | public void setBal(long bal, boolean isAdmin) {
28 | if (isAdmin) {
29 | this.bal = bal;
30 | System.out.println("Allowed");
31 | } else {
32 | System.out.println("Not Allowed!");
33 | }
34 | }
35 |
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name, boolean isAdmin) {
41 | if (isAdmin) {
42 | this.name = name;
43 | System.out.println("Allowed");
44 | } else {
45 | System.out.println("Not Allowed!");
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/ecap/Lab178.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.ecap;
2 | // ## Encapsulation
3 | public class Lab178 {
4 | public static void main(String[] args) {
5 | VWOLogin vwoLogin = new VWOLogin("admin","password123");
6 | System.out.println(vwoLogin.password);
7 | vwoLogin.password = "123";
8 | System.out.println(vwoLogin.password);
9 | }
10 | }
11 |
12 | class VWOLogin{
13 | public String username;
14 | public String password;
15 |
16 | public VWOLogin(String username, String password) {
17 | this.username = username;
18 | this.password = password;
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/ecap/Lab179.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.ecap;
2 | // ## Fixed Encapsulation
3 | public class Lab179 {
4 | public static void main(String[] args) {
5 | VWOLogin1 vwoLogin = new VWOLogin1("admin","password123");
6 | System.out.println(vwoLogin.getUsername());
7 | vwoLogin.setUsername("pramod");
8 | System.out.println(vwoLogin.getUsername());
9 |
10 | // Write a code to Auth
11 | // Pramod - isAuth = true
12 | vwoLogin.setPassword("1234",false);
13 |
14 |
15 |
16 | }
17 | }
18 |
19 | class VWOLogin1{
20 | // Data Members
21 | private String username;
22 | private String password;
23 |
24 | public String getUsername() {
25 | return username;
26 | }
27 |
28 | public void setUsername(String username) {
29 | this.username = username;
30 | }
31 |
32 | public String getPassword() {
33 | return password;
34 | }
35 |
36 | public void setPassword(String password,boolean isAuth) {
37 | if(isAuth) {
38 | this.password = password;
39 | }else {
40 | System.out.println("Not Allowed!");
41 | }
42 | }
43 |
44 | public VWOLogin1(String username, String password) {
45 | this.username = username;
46 | this.password = password;
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/ecap/Lab180.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.ecap;
2 |
3 | public class Lab180 {
4 | public static void main(String[] args) {
5 |
6 | ICICIBank amit = new ICICIBank("Amit",100);
7 | // set the balance
8 | // admin
9 |
10 | // amit.name = "dasdd";
11 | amit.setBal(1000000000,false);
12 | //amit.setBal();
13 | System.out.println(amit.getName());
14 |
15 |
16 | System.out.println(amit.getBal(false));
17 |
18 |
19 |
20 | // Write a code to connect with mySQL
21 | // Admin
22 | boolean are_you_admin = true;
23 |
24 |
25 | ICICIBank admin = new ICICIBank("admin",1000);
26 | admin.setBal(50000,true);
27 | System.out.println(admin.getName());
28 | System.out.println(admin.getBal(are_you_admin));
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/ecap/VWOLoginPage.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.ecap;
2 |
3 | public class VWOLoginPage {
4 | private String username;
5 | private String password;
6 | private String signINButton;
7 |
8 | public String getPassword() {
9 | return password;
10 | }
11 |
12 | public String getSignINButton() {
13 | return signINButton;
14 | }
15 |
16 | public String getUsername() {
17 | return username;
18 | }
19 |
20 | public void setUsername(String username) {
21 | this.username = username;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/poly/methodoveridding/Dog.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.poly.methodoveridding;
2 |
3 | public class Dog {
4 | void bark(){
5 | System.out.println("I am Dog, i will Bark!!");
6 | }
7 | int age = 10;
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/poly/methodoveridding/Hound.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.poly.methodoveridding;
2 |
3 | public class Hound extends Dog {
4 |
5 | @Override
6 | void bark(){
7 | System.out.println("I am Hound, i will Bark!!");
8 | }
9 |
10 | void bike(){
11 | System.out.println("Biked");
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/poly/methodoveridding/Lab182.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.poly.methodoveridding;
2 |
3 | public class Lab182 {
4 | // Method overidding | Runtime Poly
5 | public static void main(String[] args) {
6 | Hound h1 = new Hound();
7 | h1.bark();
8 | h1.bike();
9 |
10 | Dog d1 = new Dog();
11 | d1.bark();
12 |
13 | Dog dog_Ref = new Hound();
14 | dog_Ref.bark(); // Overriden Functions
15 | //dog_Ref.bike();
16 |
17 | //Hound h2 = new Dog();
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/poly/methodoverloading/Lab181.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.poly.methodoverloading;
2 |
3 | public class Lab181 {
4 | // Polymorphism
5 |
6 | public static void main(String[] args) {
7 | MathOperations mathOperations = new MathOperations();
8 | int result = mathOperations.add(2,3);
9 | double result2 = mathOperations.add(2.4,3.6);
10 | String result3 = mathOperations.add("Pramod","Dutta");
11 | String result4 = mathOperations.add("Pramod",123);
12 | //String result4 = mathOperations.add("Pramod",12.34);
13 | System.out.println(result);
14 | System.out.println(result2);
15 | System.out.println(result3);
16 | System.out.println(result4);
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/poly/methodoverloading/MathOperations.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.poly.methodoverloading;
2 |
3 | public class MathOperations {
4 |
5 | // Encapsulation
6 | private String name;
7 |
8 | public String getName() {
9 | return name;
10 | }
11 |
12 | public void setName(String name) {
13 | this.name = name;
14 | }
15 |
16 | int add(int a, int b) {
17 | return a + b;
18 | }
19 |
20 | // Method Overloading
21 | int add(int pramod, int dutta, int amit, int mehga) {
22 | return pramod + dutta;
23 | }
24 |
25 | void add(int a, int b, int c) {
26 | System.out.println("Hello");
27 | }
28 |
29 | double add(double a, double b) {
30 | return a + b;
31 | }
32 |
33 | double add(double a, double b, float f) {
34 | return a + b + f;
35 | }
36 |
37 | String add(String a, String b) {
38 | return a + b;
39 | }
40 |
41 | String add(String a, int b) {
42 | return a + b;
43 | }
44 |
45 | String add(int b, String a) {
46 | return a + b;
47 | }
48 |
49 | MathOperations() {
50 | }
51 |
52 | MathOperations(int a) {
53 | }
54 |
55 | MathOperations(int a, int b) {
56 | }
57 |
58 | MathOperations(int a, int b, int c) {
59 | }
60 |
61 | MathOperations(int a, int b, int c, String d) {
62 | }
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/superthiskeyword/Lab183.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.superthiskeyword;
2 |
3 | public class Lab183 {
4 | // super()
5 | //1. Use of super with Variables
6 | //2. Use of super with Methods
7 | //3. Use of super with constructors
8 |
9 | // super keyword in Java is a reference variable that allows
10 | // a subclass - child class
11 | // to refer to its parent class.
12 | public static void main(String[] args) {
13 | Car s = new Car();
14 | s.display();
15 | }
16 |
17 |
18 | }
19 |
20 | class Car extends Vehicle {
21 | private int maxSpeed = 281;
22 |
23 | Car(){
24 | super(10); // Constructor Chaining
25 | System.out.println("DC Car");
26 |
27 | }
28 |
29 | public void display(){
30 | System.out.println("Car speed is -> "+ this.maxSpeed);
31 | System.out.println("Vehicle speed is -> "+ super.maxSpeed);
32 | super.message();
33 | this.message();
34 |
35 | }
36 |
37 | @Override
38 | void message() {
39 | System.out.println("Hello Vehicle");
40 | }
41 |
42 | }
43 |
44 | class Vehicle {
45 | public int maxSpeed = 180;
46 |
47 | Vehicle(){
48 | System.out.println("DC Vehicle");
49 | }
50 | Vehicle(int a){
51 | System.out.println("PC Vehicle");
52 | }
53 |
54 |
55 | void message() {
56 | System.out.println("Hello Vehicle");
57 | }
58 |
59 | void message(int a) {
60 | System.out.println("Hello Vehicle");
61 | }
62 |
63 |
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/aug/ex_10082024/superthiskeyword/Lab184.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.superthiskeyword;
2 |
3 | public class Lab184 {
4 | }
5 |
6 |
7 | class Student extends Person {
8 | // is A relation - inheritance
9 | @Override
10 | void message() {
11 | System.out.println("I am Student message");
12 | }
13 |
14 | void display() {
15 | super.message();
16 | }
17 |
18 |
19 | }
20 |
21 | class Person {
22 | void message() {
23 | System.out.println("I am person message");
24 | }
25 | }
--------------------------------------------------------------------------------
/src/aug/ex_10082024/superthiskeyword/Lab185.java:
--------------------------------------------------------------------------------
1 | package aug.ex_10082024.superthiskeyword;
2 |
3 | public class Lab185 {
4 |
5 | // super.variable
6 | // super.method()
7 | // super() -> DC
8 | // super("pramod') -> PC
9 |
10 | // this()
11 | // this.variableName
12 |
13 |
14 |
15 | }
16 |
17 | class Person1 {
18 | Person1() {
19 | System.out.println("Person1 - DC");
20 | }
21 |
22 | Person1(String a) {
23 | System.out.println("Person1 - PC A1");
24 | }
25 |
26 | Person1(String a, int a1) {
27 | System.out.println("Person1 - PC A2");
28 | }
29 | }
30 | class Student1 extends Person1{
31 | int a = 10;
32 | Student1(String s){
33 | System.out.println("PC -Student");
34 | }
35 |
36 | Student1(){
37 | super();
38 | System.out.println(this.a);
39 | //super("Pramod");
40 | //super("pramod",12);
41 | }
42 |
43 |
44 | }
--------------------------------------------------------------------------------
/src/aug/ex_11082024/Lab186.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024;
2 |
3 | public class Lab186 {
4 | public static void main(String[] args) {
5 |
6 | }
7 | }
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/Lab207.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024;
2 |
3 | import aug.ex_17082024.COLORS;
4 |
5 | public class Lab207 {
6 | public static void main(String[] args) {
7 | System.out.println("Color Code "+ COLORS.RED);
8 | System.out.println("Color Code "+ COLORS.RED.getValue());
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/RealLIFEex/BaseClass.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.RealLIFEex;
2 |
3 | abstract class BaseClass extends GrandBaseClass {
4 | // Web Automation
5 | // Single
6 | // Hide the Functionality of the open and close Browser.
7 |
8 | abstract String openBrowser(String browser);
9 | abstract String closeBrowser(String browser);
10 | BaseClass(){}
11 |
12 | @Override
13 | void takeScreenShot() {
14 | System.out.println("Ok Taking ScreenShot");
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/RealLIFEex/CHOMRE.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.RealLIFEex;
2 |
3 | public class CHOMRE extends BaseClass{
4 | @Override
5 | String openBrowser(String browser) {
6 | System.out.println("Open the Chrome ....., // This is code releted to chrome only\n");
7 | return browser;
8 | }
9 |
10 | @Override
11 | String closeBrowser(String browser) {
12 | return "";
13 | }
14 |
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/RealLIFEex/FIREFOX.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.RealLIFEex;
2 |
3 | public class FIREFOX extends BaseClass {
4 | @Override
5 | String openBrowser(String browser) {
6 | System.out.println("Open the FIREFOX ....., // This is code releted to FIREFOX only\n");
7 | return browser;
8 | }
9 |
10 | @Override
11 | String closeBrowser(String browser) {
12 | System.out.println("Closing the FIREFOX ....., // This is code releted to FIREFOX only\n");
13 | return "";
14 | }
15 |
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/RealLIFEex/GrandBaseClass.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.RealLIFEex;
2 |
3 | abstract class GrandBaseClass {
4 | abstract void takeScreenShot();
5 |
6 | GrandBaseClass(){}
7 |
8 | // new GrandBaseClass();
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/RealLIFEex/Lab189.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.RealLIFEex;
2 |
3 | public class Lab189 {
4 | public static void main(String[] args) {
5 | CHOMRE c = new CHOMRE();
6 | String s = c.openBrowser("Chrome");
7 | System.out.println(s);
8 | c.closeBrowser("Chrome");
9 |
10 | FIREFOX f = new FIREFOX();
11 | f.openBrowser("ff");
12 | f.closeBrowser("ff");
13 | f.takeScreenShot();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/exLoan/Father.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.exLoan;
2 |
3 | abstract class Father {
4 | abstract void loan50K();
5 |
6 | void loan25k(){
7 | System.out.println("Done by Father Already");
8 | }
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/exLoan/Lab188.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.exLoan;
2 |
3 | public class Lab188 {
4 | public static void main(String[] args) {
5 | Son s1 = new Son();
6 | s1.loan50K();
7 |
8 | Father f1 = new Son();
9 | f1.loan25k();
10 | f1.loan50K();
11 |
12 |
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/exLoan/Son.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.exLoan;
2 |
3 | public class Son extends Father {
4 | @Override
5 | void loan50K() {
6 | System.out.println("I will give the Loan 50K");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/Engine.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface;
2 |
3 | public interface Engine {
4 | void startEngine(); // Incomplete
5 | void stopEngine(); // Incomplete
6 | }
7 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/Lab190.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface;
2 |
3 | public class Lab190 {
4 | // Interface - Hide the implementation
5 | // Interface variables will be inherited to subclasses.
6 | // interface is a keyword which is used to define User Defined Datatypes.
7 |
8 |
9 | public static void main(String[] args) {
10 | // Engine e = new Engine();
11 | WagonR r = new WagonR();
12 | r.drive();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/Lab191.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface;
2 |
3 | public class Lab191 {
4 | public static void main(String[] args) {
5 | // I i = new I():
6 |
7 | }
8 | }
9 |
10 | interface I{}
11 | class A{} // con
12 | class B{}
13 | abstract class C{}
14 | class Test1 extends A{} // Ok?
15 | class Test2 extends B{}
16 | // class Test3 extends A,B{} // Multiple Inheritance
17 | class Test0 implements I{}
18 | interface I1{ }
19 | interface I2{}
20 | class Test4 implements I1,I2{} // multiple Inheritance with interface
21 | class Test5 extends A implements I1,I2{}
22 | //class Test6 implements I1 extends A{}// Ok
23 | //interface I3 extends A{}
24 | //interface I4 implements A{}
25 | //interface I5 extends A,B{}
26 | interface I6 extends I1,I2{}
27 | //interface I7 extends C{}
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/WagonR.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface;
2 |
3 | public class WagonR implements Engine{
4 |
5 | void drive(){
6 | startEngine();
7 | stopEngine();
8 | }
9 |
10 | @Override
11 | public void startEngine() {
12 | System.out.println("Wagon R i starting");
13 | }
14 |
15 | @Override
16 | public void stopEngine() {
17 | System.out.println("Wagon R i Stopping");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/ex2/CarC.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.ex2;
2 |
3 | public class CarC implements E{
4 | @Override
5 | public void startEngine() {
6 |
7 | }
8 |
9 | @Override
10 | public void stopEngine() {
11 |
12 | }
13 |
14 | @Override
15 | public void m2() {
16 |
17 | }
18 |
19 | @Override
20 | public void m3() {
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/ex2/E.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.ex2;
2 |
3 | public interface E {
4 | void startEngine();
5 |
6 | void stopEngine();
7 |
8 | default void haltingEngineJustStart() {
9 | System.out.println("Halt the Engine");
10 | }
11 |
12 | default void haltingEngineJustStop() {
13 | System.out.println("Halt the Engine");
14 | }
15 |
16 | static void M1() {
17 | System.out.println("M1");
18 | }
19 |
20 | void m2();
21 | void m3();
22 | // void m4(){
23 | // System.out.println("Not possible");
24 | // }
25 | }
26 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/ex2/PramodA.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.ex2;
2 |
3 | abstract class PramodA {
4 |
5 | abstract void m1();
6 | void m2(){
7 |
8 | }
9 | }
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/ex3/Lab192.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.ex3;
2 |
3 | import java.security.Key;
4 |
5 | public class Lab192 {
6 | public static void main(String[] args) {
7 | Car c = new Car();
8 | c.start();
9 | c.m1();
10 | }
11 | }
12 |
13 | interface Eng{
14 | void start();
15 | default void m1(){
16 | System.out.println("Old M1");
17 | }
18 |
19 | default void suite(){
20 | System.out.println("wear suite");
21 | }
22 | }
23 |
24 | interface GearBox extends Eng{
25 | void gear();
26 |
27 | }
28 |
29 | interface Keys extends GearBox{
30 | void openCar();
31 | }
32 |
33 |
34 |
35 | class Car implements Keys {
36 |
37 | @Override
38 | public void start() {
39 | System.out.println("Starting");
40 | }
41 |
42 | @Override
43 | public void gear() {
44 |
45 | }
46 |
47 | @Override
48 | public void openCar() {
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/multipleinheritnace/Father.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.multipleinheritnace;
2 |
3 | interface Father {
4 | void loan();
5 | void loan(String a);
6 | void home();
7 |
8 | static void m1(){
9 | System.out.println("Let me explain");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/multipleinheritnace/Lab192.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.multipleinheritnace;
2 |
3 | public class Lab192 {
4 | public static void main(String[] args) {
5 | Son s1 = new Son();
6 | s1.loan();
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/multipleinheritnace/Mother.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.multipleinheritnace;
2 |
3 | //interface to interface extends
4 | //class to class extends
5 | //interface to class implements
6 | interface Mother {
7 | void loan();
8 | void loan(String b, String c);
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/ex_interface/multipleinheritnace/Son.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.ex_interface.multipleinheritnace;
2 |
3 | public class Son implements Father,Mother{
4 |
5 | @Override
6 | public void loan() {
7 | System.out.println("This is only One Function");
8 | }
9 |
10 | @Override
11 | public void loan(String b, String c) {
12 | System.out.println("String b, String c");
13 | }
14 |
15 | @Override
16 | public void loan(String a) {
17 | System.out.println("String a");
18 | }
19 |
20 | @Override
21 | public void home() {
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/Car.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | class Car extends Engine {
4 | // Engine
5 | // GearBox
6 | // Keys
7 |
8 | // Tesla is A Car
9 | // Tesla - DRIVE()
10 |
11 |
12 | @Override
13 | void openCar() {
14 | System.out.println("Open Car with keys");
15 | }
16 |
17 | @Override
18 | void partGearBox() {
19 | System.out.println("Part of GearBox");
20 | }
21 |
22 | @Override
23 | void stop() {
24 | System.out.println("Stop a Car");
25 | }
26 |
27 | @Override
28 | void speed() {
29 | System.out.println("Car");
30 | }
31 |
32 | @Override
33 | void start() {
34 | System.out.println("Start a Car");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/Engine.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | abstract class Engine extends GearBox{
4 | // Incomplete class
5 | abstract void start();
6 | abstract void stop();
7 | abstract void speed();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/GearBox.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | abstract class GearBox extends Keys {
4 | abstract void partGearBox();
5 | }
6 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/Keys.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | abstract class Keys {
4 | abstract void openCar();
5 | }
6 |
7 |
8 | class ConcreateClass{
9 | // no keyword of abstract in the area
10 | }
11 |
12 | abstract class IncompleteAbstractClass{
13 | abstract void f1();
14 | abstract String f2();
15 | abstract boolean f3();
16 | abstract long f4();
17 | }
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/Lab187.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | public class Lab187 {
4 | public static void main(String[] args) {
5 |
6 |
7 | Tesla t = new Tesla();
8 | t.drive();
9 |
10 | System.out.println(" --- --- ");
11 | WagonR wagonR = new WagonR();
12 | wagonR.drive();
13 |
14 |
15 |
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/Tesla.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | public class Tesla extends Engine{
4 | void drive(){
5 | openCar();
6 | start();
7 | partGearBox();
8 | stop();
9 | }
10 |
11 | @Override
12 | void start() {
13 | System.out.println("Starting Tesla");
14 | }
15 |
16 | @Override
17 | void stop() {
18 | System.out.println("Stopping Tesla");
19 |
20 | }
21 |
22 | @Override
23 | void speed() {
24 | System.out.println("300km.hr");
25 |
26 | }
27 |
28 | @Override
29 | void partGearBox() {
30 | System.out.println("electric");
31 |
32 | }
33 |
34 | @Override
35 | void openCar() {
36 | System.out.println("open Tesla");
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/WagonR.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | public class WagonR extends Engine{
4 |
5 | void drive(){
6 | openCar();
7 | start();
8 | partGearBox();
9 | speed();
10 | stop();
11 |
12 | }
13 |
14 | @Override
15 | void start() {
16 | System.out.println("Starting Wagon R");
17 | }
18 |
19 | @Override
20 | void stop() {
21 | System.out.println("Stop Wagon R");
22 |
23 | }
24 |
25 | @Override
26 | void speed() {
27 | System.out.println("100KM/Hr");
28 | }
29 |
30 | @Override
31 | void partGearBox() {
32 | System.out.println("Wagon/Hr");
33 |
34 | }
35 |
36 | @Override
37 | void openCar() {
38 | System.out.println("open Keys");
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/excar/i10.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.excar;
2 |
3 | public class i10 extends Car{
4 | void drivei10(){
5 | openCar();
6 | start();
7 | partGearBox();
8 | stop();
9 | }
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/aug/ex_11082024/staticKeywrod/Lab193.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.staticKeywrod;
2 |
3 | public class Lab193 {
4 | // Static
5 | // block
6 | // Data member
7 | // Function
8 | // Class
9 |
10 | public static void main(String[] args) {
11 | ATB a1 = new ATB("amit");
12 | }
13 | }
14 |
15 |
16 | class ATB{
17 |
18 | {
19 | System.out.println("IIB");
20 | // What is the purpose? -
21 | // Here you can write code related to
22 | // start a webite or anything before starting the
23 | // web automation or api automation
24 | //
25 | System.out.println("Reading from CSV file");
26 | }
27 |
28 | static {
29 | System.out.println("Load the class?, I will execute");
30 | }
31 |
32 |
33 |
34 | private String name;
35 | private String phone;
36 | static String courseName = "ATB";
37 |
38 | public String getName() {
39 | return name;
40 | }
41 |
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | public ATB(String name) {
47 | this.name = name;
48 | }
49 |
50 | static void doAssignment(){
51 | System.out.println("Do Assignment");
52 | }
53 |
54 | static class A{
55 |
56 | }
57 | }
--------------------------------------------------------------------------------
/src/aug/ex_11082024/staticKeywrod/Lab194.java:
--------------------------------------------------------------------------------
1 | package aug.ex_11082024.staticKeywrod;
2 |
3 | public class Lab194 {
4 | }
5 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/APIConstants.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public enum APIConstants {
4 | BASE_URL("https://app.vwo.com"),
5 | LOGIN_PAGE("https://app.vwo.com/login"),
6 | DASHBOARD_PAGE("https://app.vwo.com/dasHboard"),
7 | CHATBOT_PAGE("https://app.vwo.com/chat");
8 |
9 |
10 | private final String name;
11 |
12 | APIConstants(String name) {
13 | this.name = name;
14 | }
15 |
16 | public String getValue() {
17 | return name;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/BUG.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public enum BUG {
4 | LOW,
5 | MEDIUM,
6 | HIGH
7 | }
8 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/COLORS.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public enum COLORS {
4 | RED("#ff0000"),
5 | GREEN("#f0d0d0d"),
6 | BLUE("#f0d0d0d");
7 |
8 |
9 | private final String hexValue;
10 |
11 | COLORS(String hexValue) {
12 | this.hexValue = hexValue;
13 | }
14 |
15 | public String getValue(){
16 | return hexValue;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab195.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 | // Wrapper Classes
3 |
4 | public class Lab195 {
5 | public static void main(String[] args) {
6 | int a = 10;
7 | // Data Type -> int
8 | // primitive - data type
9 | System.out.println(a);
10 |
11 |
12 | // Java like everything should a Class or Object - OOPs
13 | Integer a1 = 10;
14 |
15 |
16 |
17 |
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab196.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab196 {
4 | public static void main(String[] args) {
5 | // Primitive to Wrapper class
6 | int a = 10;
7 | Integer b = a;
8 | // Integer.MAX_VALUE
9 | System.out.println(a);
10 | System.out.println(b);// extra utilities are added.
11 | System.out.println(b);// extra utilities are added.
12 |
13 |
14 |
15 |
16 | // Wrapper class to Primitive
17 | Integer a2 = 42; // Auto Boxing - int -> Integer
18 | int value = a2; // UnBoxing - Integer -> int
19 | System.out.println(a2);
20 | System.out.println(value);
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab197.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab197 {
4 | public static void main(String[] args) {
5 | String num = "10";
6 | //int a = (int)num;
7 | Integer a = Integer.valueOf(num);
8 | System.out.println(a);
9 |
10 | // String to Primitive?
11 | int a2 = Integer.parseInt(num);
12 | System.out.println(a2);
13 |
14 | // String -> int, Integer
15 | // Primitive to Wrapper or reverse then you will use the concept.
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab198.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab198 {
4 | public static void main(String[] args) {
5 | Double d = 3.14; // HEAP
6 | double val = d.doubleValue(); // CM
7 | System.out.println(d);
8 | System.out.println(val);
9 |
10 | String s1 = "pramod"; // SCP
11 | String s2 = new String("pramod"); // HEAP
12 |
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab199.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab199 {
4 | public static void main(String[] args) {
5 | A a = new A();
6 | A a2 = new A();
7 |
8 | a.age = 12;
9 | System.out.println(A.discount);
10 | a.m2();
11 | A.m1(); // Static
12 |
13 | // Static don't need object ref. - True
14 |
15 | }
16 | }
17 |
18 |
19 |
20 | class A{
21 | int age = 10; // Instance variable
22 | static int discount = 199; // static variable
23 |
24 | // SIB - STATIC initialization block
25 | static {
26 | System.out.println("One Time Load SIB");
27 | }
28 |
29 | // IIB - instance initialization block
30 | {
31 | System.out.println("IIB When Object is created");
32 | }
33 |
34 | static void m1(){
35 | System.out.println("m1");
36 | }
37 | void m2(){
38 | System.out.println("m2");
39 | System.out.println(discount);
40 | }
41 | }
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab200.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab200 {
4 | public static void main(String[] args) {
5 | APIAutomation a = new APIAutomation();
6 | // SIB - call 1 time
7 | // IIB - when object is created.
8 | }
9 | }
10 |
11 | class APIAutomation{
12 |
13 | static {
14 | // write a code to load the data from the MySQL
15 | System.out.println("Loaded data from the MYSQL");
16 | }
17 |
18 | {
19 | // write a code to load the data from the CSV file
20 | System.out.println("Loaded data from the CSV");
21 |
22 | }
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab201.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab201 {
4 | }
5 |
6 | // Nested Class - Rarely you will be using it
7 |
8 | class OC{
9 | Integer a = 10;
10 |
11 | void OC_m1(){
12 | // System.out.println(b);
13 | System.out.println("OC_M1");
14 | }
15 |
16 | static class P{
17 |
18 | }
19 |
20 |
21 | class InnerClass{
22 | Integer b = 20;
23 | void Inner_m2(){
24 | System.out.println(a);
25 | System.out.println("IC_M2");
26 |
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab202.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab202 {
4 | public static void main(String[] args) {
5 | Car c = new Car("Lambo");
6 | c.drive();
7 | // System.out.println(c.make);
8 |
9 | // to access the inner class Object creation.
10 | Car.GearBox cg = c.new GearBox();
11 | cg.m2();
12 |
13 |
14 | }
15 | }
16 |
17 |
18 | class Car {
19 | private String make;
20 |
21 | public Car(String make) {
22 | this.make = make;
23 | }
24 |
25 | // Method
26 | void drive() {
27 | System.out.println("You can driver Car");
28 | }
29 |
30 | class GearBox {
31 | void m2() {
32 | System.out.println("m2");
33 | }
34 | class NutBolts{
35 |
36 | }
37 |
38 | }
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab203.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab203 {
4 | public static void main(String[] args) {
5 | // Anonymous Class
6 |
7 | ABC a = new ABC() {
8 | @Override
9 | public void m1() {
10 | System.out.println("m1");
11 | }
12 |
13 | @Override
14 | public void m2() {
15 | System.out.println("m2");
16 | }
17 | };
18 |
19 | CBA a1 = new CBA() {
20 | @Override
21 | void m3() {
22 | System.out.println("M3");
23 | }
24 | };
25 |
26 | }
27 | }
28 |
29 |
30 | interface ABC{
31 | void m1();
32 | void m2();
33 | }
34 |
35 | abstract class CBA{
36 | abstract void m3();
37 | }
38 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab205.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab205 {
4 | public static void main(String[] args) {
5 | System.out.println("BUG value -" + BUG.LOW);
6 |
7 | System.out.println("I am working on "+ PAGES.CHATBOTPAGE);
8 |
9 |
10 | System.out.println("Color Code "+ COLORS.RED);
11 | System.out.println("Color Code "+ COLORS.RED.getValue());
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab206.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab206 {
4 | public static void main(String[] args) {
5 | System.out.println("Color Code "+ COLORS.RED);
6 | System.out.println("Color Value "+ COLORS.RED.getValue());
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab208.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab208 {
4 | public static void main(String[] args) {
5 | System.out.println(APIConstants.LOGIN_PAGE);
6 | System.out.println(APIConstants.LOGIN_PAGE.getValue());
7 |
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab209.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab209 {
4 | public static void main(String[] args) {
5 | System.out.println("Start of the program");
6 |
7 | String ip = args[0]; // ArrayIndexOutOfBoundsException
8 | int a = Integer.parseInt(ip); // NumberFormatException
9 | int b = 1000/a; // ArithmeticException
10 | System.out.println(b);
11 | System.out.println("End of the program");
12 |
13 | //JVM will be Initialized
14 | //Creates and Starts the main Thread. - Main Called
15 | //1)Collects the Command Line Arguments
16 | //2)Creates the String array with CLI
17 | //3. Lab209.main(0)
18 | //Now Control will be transferred from main Thread to main method
19 | // When problem comes in main -> JVM
20 | // If don't handle the exception JVM -
21 | // Exception a=new Exception() and terminate the program. G
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab210.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | import java.io.File;
4 | import java.io.FileInputStream;
5 | import java.io.FileNotFoundException;
6 |
7 | public class Lab210 {
8 | public static void main(String[] args) {
9 | // Exception
10 | // Checked - JVM knows -
11 | // try {
12 | // FileInputStream file = new FileInputStream("C://log.txt");
13 | // } catch (FileNotFoundException e) {
14 | // throw new RuntimeException(e);
15 | // }
16 |
17 |
18 | // UnChecked
19 | try {
20 | int a = 10;
21 | int c = a/0; // java.lang.ArithmeticException
22 | System.out.println("c");
23 | } catch (Exception e) {
24 | System.out.println("Error / by zero");
25 | }
26 |
27 | System.out.println("End of program");
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab211.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab211 {
4 | public static void main(String[] args) {
5 | int c = 0;
6 | try {
7 | c = 10/0;
8 | } catch (Exception e) {
9 | System.out.println("/ by zero!!, You fool!!");
10 | }
11 | System.out.println(c);
12 | System.out.println("End");
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab212.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab212 {
4 | public static void main(String[] args) {
5 | System.out.println("Start of the program");
6 |
7 | int b = 0; // ArithmeticException
8 | try {
9 | String ip = args[0]; // ArrayIndexOutOfBoundsException
10 | int a = Integer.parseInt(ip); // NumberFormatException
11 | b = 1000/a;
12 | } catch (ArithmeticException| NumberFormatException | ArrayIndexOutOfBoundsException e) {
13 | System.out.println(e.getMessage());
14 | }
15 | System.out.println(b);
16 | System.out.println("End of the program");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab213.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab213 {
4 | public static void main(String[] args) {
5 | System.out.println("Start of the program");
6 |
7 | String ip = null; // ArrayIndexOutOfBoundsException
8 | try {
9 | ip = args[0];
10 | } catch (ArrayIndexOutOfBoundsException e) {
11 | throw new RuntimeException(e);
12 | }
13 | int a = 0; // NumberFormatException
14 | try {
15 | a = Integer.parseInt(ip);
16 | } catch (NumberFormatException e) {
17 | throw new RuntimeException(e);
18 | }
19 | int b = 0; // ArithmeticException
20 | try {
21 | b = 1000 / a;
22 | } catch (ArithmeticException e) {
23 | throw new RuntimeException(e);
24 | }
25 | System.out.println(b);
26 | System.out.println("End of the program");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab214.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab214 {
4 | public static void main(String[] args) {
5 | try {
6 | String s1 = "Pramod";
7 | String a1 = args[0];
8 | int a = 10 / 0;
9 | s1 = null;
10 | System.out.println(s1.trim());
11 | } catch (Exception e) {
12 | System.out.println("There is some problem with the code");
13 | System.out.println(e.getMessage());
14 | }
15 |
16 |
17 | System.out.println("End of Program!");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab215.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab215 {
4 | public static void main(String[] args) {
5 | final double pi = 3.14;
6 | int a= 0;
7 | try {
8 | int x = 10/a;
9 | } catch (Exception e) {
10 | System.out.println("div by Zero");
11 | } finally {
12 | System.out.println("I will be executed anyHow!!");
13 | }
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab216.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public class Lab216 {
4 | public static void main(String[] amit) {
5 |
6 | try {
7 | int a = 10/0;
8 | } catch (Exception pramod) {
9 | System.out.println("Div by Zero");
10 | //pramod.getMessage()
11 | } finally {
12 | System.out.println("I will be always Executed, anyHow!!");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/Lab217.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | import java.io.File;
4 | import java.io.FileNotFoundException;
5 | import java.io.FileReader;
6 |
7 | public class Lab217 {
8 | public static void main(String[] args) {
9 | try {
10 | int a = 10/0; // Uncheck Ath E
11 | } catch (Exception e) {
12 | throw new RuntimeException(e);
13 | }
14 |
15 | try {
16 | FileReader f = new FileReader(new File("c://a.txt"));
17 | } catch (FileNotFoundException e) {
18 | throw new RuntimeException(e);
19 | }
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/aug/ex_17082024/PAGES.java:
--------------------------------------------------------------------------------
1 | package aug.ex_17082024;
2 |
3 | public enum PAGES {
4 | LOGINPAGE,
5 | DASHBOARDPAGE,
6 | SUPPORTPAGE,
7 | CHATBOTPAGE
8 | }
9 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Bank.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | public class Bank {
4 | private String currency;
5 | private Integer amount;
6 |
7 | public Bank(String currency, Integer amount) {
8 | this.currency = currency;
9 | this.amount = amount;
10 | }
11 |
12 | public String getCurrency() {
13 | return currency;
14 | }
15 |
16 | public void setCurrency(String currency) {
17 | this.currency = currency;
18 | }
19 |
20 | public Integer getAmount() {
21 | return amount;
22 | }
23 |
24 | public void setAmount(Integer amount) {
25 | this.amount = amount;
26 | }
27 |
28 | public Integer add(Bank bankName){
29 | if(!bankName.currency.equalsIgnoreCase("INR")){
30 | // throw exception that it is not supported - USD, gBP + INR
31 | try {
32 | throw new Exception("Currency Doesn't Match!");
33 | } catch (Exception e) {
34 | throw new RuntimeException(e);
35 | }
36 |
37 | }
38 | Integer sum = this.amount + bankName.amount;
39 | return sum;
40 | }
41 |
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab227.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | public class Lab227 {
4 | public static void main(String[] args) {
5 | // Collection Framework
6 |
7 |
8 | // Array
9 | Integer [] arr = new Integer[10];
10 | int[] arr2 = new int[10];
11 |
12 | arr[0] = 11;
13 |
14 | // Size -> Fixed Size Problem in array.
15 | // // Can I increase the size of the array?
16 | // arr2.sort()
17 | // find something the array?
18 | // There are not in built functions available in the arrays
19 | // sorting, updating, delete, increasing size, decrease size.
20 | // appending, finding ...
21 | // array can store one type of data type
22 |
23 |
24 | // ArrayList -> this has solved all the problem
25 |
26 |
27 | // JDK 1.2 - 1997
28 | // Legacy Classes
29 | // Vector
30 | // Stack
31 | // Properties
32 | // Hash table
33 | // Dictionary
34 |
35 |
36 | // JDK 22 - Advance Collection Class that we can use.
37 |
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab228.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collection;
5 | import java.util.List;
6 |
7 | public class Lab228 {
8 | public static void main(String[] args) {
9 | // Collections Framework
10 | // Collection - Interface
11 | // Collection(I) -> List (I)
12 | // List (I) -> ArrayList, LinkedList, Vector, Stack
13 |
14 | // Shopping List, Marks List, Collection of items, Todo List, Student List.
15 | // Collection mylist3 = new ArrayList(); // Dynamic Dispatch
16 | // List mylist = new ArrayList(); // Dynamic Dispatch
17 | //
18 | ArrayList mylist2 = new ArrayList();
19 | mylist2.add("Pramod");
20 | mylist2.add("Amit");
21 | mylist2.add("lucky");
22 | mylist2.add("Muthu");
23 | mylist2.add(123);
24 | mylist2.add(true);
25 |
26 | System.out.println(mylist2); // [Pramod, Amit, lucky, Muthu]
27 | System.out.println(mylist2.size()); // 4
28 | System.out.println(mylist2.contains("Amit")); // true
29 | System.out.println(mylist2.contains("Hemalata")); // false
30 | String s1 = (String) mylist2.get(1);
31 | System.out.println(s1);
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab229.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class Lab229 {
7 | public static void main(String[] args) {
8 | int [] a = new int[5];
9 | a[0] = 1;
10 | a[1] = 2;
11 | a[2] = 3;
12 | a[3] = 4;
13 | a[4] = 5;
14 |
15 | for (int i = 0; i < a.length ; i++) {
16 | if( a[i] == 4){
17 | System.out.println("Found 4");
18 | }
19 | }
20 |
21 | ArrayList arr = new ArrayList();
22 | arr.add(1);
23 | arr.add(2);
24 | arr.add(3);
25 | arr.add(4);
26 | arr.add(5);
27 | System.out.println(arr.contains(4));
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab230.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.List;
4 |
5 | public class Lab230 {
6 | public static void main(String[] args) {
7 | List shopping_list = List.of("Milk","Bread","Butter","Cheese");
8 | System.out.println(shopping_list);
9 | System.out.println(shopping_list.size());
10 | shopping_list.add("Banana");
11 |
12 |
13 |
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab231.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class Lab231 {
7 | public static void main(String[] args) {
8 | List mylist = new ArrayList();
9 | mylist.add("Pramod");
10 | mylist.add("Anusha");
11 | mylist.add("Kiran");
12 | mylist.add("Pramod"); // Duplicate
13 | mylist.add("Pramod");
14 | // add, remove, clear, contains, indexOf, isEmpty, size, get
15 | // addAll, removeAll, retainAll, containsAll
16 | System.out.println(mylist);
17 | System.out.println(mylist.size());
18 | mylist.remove("Pramod");
19 | // Removes the first occurrence of the specified element from this list,
20 | System.out.println(mylist);
21 | mylist.clear();
22 | System.out.println(mylist);
23 | System.out.println(mylist.isEmpty());
24 |
25 | mylist.add("Pramod");
26 | mylist.add("Anusha");
27 | mylist.add("Kiran");
28 | mylist.add("Pramod"); // Duplicate
29 | mylist.add("Pramod");
30 |
31 | System.out.println(mylist);
32 | mylist.add("Dutta");
33 | System.out.println(mylist);
34 | mylist.set(1, "AnushaDutta");
35 | System.out.println(mylist);
36 |
37 | mylist.add(123);
38 | mylist.add(true);
39 | System.out.println(mylist);
40 |
41 | System.out.println(" - - - -- " );
42 |
43 | // hOw to print?
44 | for (int i = 0; i < mylist.size(); i++) {
45 | System.out.println(mylist.get(i));
46 | }
47 |
48 | System.out.println(" - - - -- " );
49 |
50 |
51 | // Enhanced For loop
52 | for (Object o: mylist){
53 | System.out.println(o);
54 | }
55 |
56 |
57 |
58 |
59 |
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab232.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collections;
5 | import java.util.Comparator;
6 | import java.util.List;
7 |
8 | public class Lab232 {
9 | public static void main(String[] args) {
10 | List marks = new ArrayList();
11 | marks.add(91);
12 | marks.add(95);
13 | marks.add(56);
14 | marks.add(89);
15 | System.out.println(marks);
16 | // Collections.sort(marks);
17 | Collections.sort(marks, Comparator.reverseOrder());
18 | System.out.println(marks);
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab233.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collections;
5 | import java.util.List;
6 |
7 | public class Lab233 {
8 | public static void main(String[] args) {
9 | List marks = new ArrayList();
10 | marks.add(100);
11 | // marks.add("pramod");
12 | // marks.add(true);
13 | // Collection -I
14 | // Collections -C
15 |
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab234.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Iterator;
5 | import java.util.List;
6 |
7 | public class Lab234 {
8 | public static void main(String[] args) {
9 | List mylist = new ArrayList();
10 | mylist.add("Pramod");
11 | mylist.add("Amit");
12 | mylist.add("Dutta");
13 |
14 | System.out.println(" - To Print Arraylist - 1 ");
15 |
16 | for (String str : mylist) {
17 | System.out.println(str);
18 | }
19 |
20 | System.out.println(" - To Print Arraylist - 2 ");
21 |
22 | for (int i = 0; i < mylist.size(); i++) {
23 | System.out.println(mylist.get(i));
24 | }
25 |
26 | System.out.println(" - To Print Arraylist - 3 ");
27 |
28 | // Iterator
29 | Iterator its = mylist.iterator();
30 | while(its.hasNext()){
31 | System.out.println(its.next());
32 | }
33 |
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/CollectionFramework/Lab235.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024.CollectionFramework;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Vector;
6 |
7 | public class Lab235 {
8 | public static void main(String[] args) {
9 | List mylist1 = new ArrayList(5); // FR - CO
10 | mylist1.add("Pramod");
11 | mylist1.add("Anusha");
12 | mylist1.add("Kiran");
13 | mylist1.add("Kiran");
14 | mylist1.add("Kiran");
15 | mylist1.add("Kiran");
16 | System.out.println(mylist1);
17 |
18 | Vector v = new Vector();
19 | v.add("Pramod"); // t1
20 | v.add("Anusha"); // t1
21 | v.add("Kiran"); // t1
22 | System.out.println(v);
23 | // Only Problem with the Vector
24 | // - It is Thread Safe, Synchronised.
25 | // It will be time consumming
26 | // One by One - usage
27 | // Slower
28 |
29 |
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab218.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | public class Lab218 {
4 |
5 | public static void main(String[] args) {
6 | extracted();
7 | }
8 |
9 | private static void extracted() {
10 | extracted1();
11 | }
12 |
13 | private static void extracted1() {
14 | try {
15 | Integer[] i = new Integer[2];
16 | System.out.println(i[3]); // Unchecked - ArrayIndexOutOfBoundsException
17 | } catch (Exception e) {
18 | System.out.println("ArrayIndexOutofBound");
19 | }finally {
20 | // File.close, sc.close, sqlconnection.close.
21 | System.out.println("End of the program");
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab219.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | import java.io.File;
4 | import java.io.FileReader;
5 |
6 | public class Lab219 {
7 | public static void main(String[] args) {
8 | String path = "C://a.txt";
9 | File file = new File(path);
10 | try {
11 | FileReader fileReader = new FileReader(file);
12 | } catch (Exception e) {
13 | System.out.println("FNE");
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab220.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | import java.io.File;
4 | import java.io.FileNotFoundException;
5 | import java.io.FileReader;
6 |
7 | public class Lab220 {
8 | public static void main(String[] args) throws FileNotFoundException ,ArithmeticException {
9 | readFile();
10 | }
11 |
12 | private static void readFile() throws FileNotFoundException,ArithmeticException {
13 | System.out.println("Hello Pramod");
14 | String path = "/Users/promode/Downloads/Ad1.mp4";
15 | File file = new File(path);
16 | FileReader fileReader = new FileReader(file);
17 |
18 | // read the file txt it can read the file
19 | System.out.println("End of the program");
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab221.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | import java.io.File;
4 | import java.io.FileNotFoundException;
5 | import java.io.FileReader;
6 |
7 | public class Lab221 {
8 | public static void main(String[] args) throws FileNotFoundException {
9 | try {
10 | int a = 10 / 0; // un - ar
11 | } catch (ArithmeticException | NullPointerException | ArrayIndexOutOfBoundsException e) {
12 | System.out.println("e1");
13 |
14 | }catch (Exception e2){
15 | System.out.println("e2");
16 | }finally {
17 | System.out.println("FF");
18 | }
19 |
20 | FileReader f = new FileReader(new File("/Users/promode/Downloads/Ad1.mp4"));
21 |
22 |
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab222.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | public class Lab222 {
4 | public static void main(String[] args) throws Exception {
5 | // throw
6 | // Custom Exception
7 | Bank sbi = new Bank("INR", 100);
8 | // Bank icici = new Bank("INR", 10);
9 | // Integer total = sbi.add(icici);
10 | // System.out.println(total);
11 |
12 | Bank jpmorgan = new Bank("AED", 89);
13 | Integer totalnew = sbi.add(jpmorgan);
14 | System.out.println(totalnew);
15 |
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab223.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | import java.util.Scanner;
4 |
5 | public class Lab223 {
6 | public static void main(String[] args) {
7 | Scanner sc = new Scanner(System.in);
8 | System.out.println("Enter your name");
9 | String name = sc.next();
10 | if (name.equalsIgnoreCase("Pramod")){
11 | try {
12 | throw new Exception("Not allowed!!");
13 | } catch (Exception e) {
14 | System.out.println("Exception!!");
15 | }
16 | }else {
17 | System.out.println("Allowed!");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab224.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | import java.util.Scanner;
4 |
5 | public class Lab224 {
6 | public static void main(String[] args) {
7 | Scanner sc = new Scanner(System.in);
8 | int x = sc.nextInt();
9 | try {
10 | if( x == 0){
11 | throw new ArithmeticException("Enter non zero number");
12 | }
13 | int a = 10/x;
14 | System.out.println(a);
15 | } catch (ArithmeticException e) {
16 | throw new RuntimeException(e);
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab225.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | public class Lab225 {
4 | public static void main(String[] args) {
5 | try {
6 | String s1 = null;
7 | if (s1 == null){
8 | throw new Exception("Add a proper String or not null String");
9 | }
10 | s1.trim();
11 | } catch (Exception e) {
12 | throw new RuntimeException(e);
13 | }
14 | //
15 |
16 |
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/aug/ex_18082024/Lab226.java:
--------------------------------------------------------------------------------
1 | package aug.ex_18082024;
2 |
3 | public class Lab226 extends Object {
4 | public static void main(String[] args) {
5 | String name = "Dramod"; // pramod
6 | String name2 = "pramod"; // pramod
7 | if (name.equalsIgnoreCase(name2)){
8 | System.out.println("Equal");
9 | }else {
10 | System.out.println("Not EQUAL");
11 | }
12 |
13 | // final -> constant
14 | // finally -> block of code with the try and catch
15 | // finalize -> Object class function - threading use case
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab236.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedList;
5 |
6 | public class Lab236 extends Object {
7 | public static void main(String[] args) {
8 | LinkedList l = new LinkedList();
9 | l.add("Node 1");
10 | l.add("Node 2");
11 | l.add("Node 3");
12 | System.out.println(l);
13 |
14 |
15 | ArrayList l2 = new ArrayList();
16 | l2.add("Node 1");
17 | l2.add("Node 2");
18 | l2.add("Node 3");
19 | System.out.println(l2);
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab237.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.ArrayList;
4 | import java.util.LinkedList;
5 | import java.util.Stack;
6 |
7 | public class Lab237 {
8 | public static void main(String[] args) {
9 | // Vector, Stack - Legacy - 95% of time we are not going to use it in automation
10 | // legacy? - old ->
11 |
12 | Stack s = new Stack();
13 | s.push("Pramod");
14 | s.push("Dutta");
15 | s.push("Amit");
16 | s.add("Amit2");
17 | System.out.println(s);
18 | System.out.println(s.peek());
19 | System.out.println(s.pop());
20 |
21 | System.out.println(s);
22 |
23 |
24 |
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab238.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.*;
4 |
5 | public class Lab238 {
6 | public static void main(String[] args) {
7 | // Student - name, id
8 | Student s1 = new Student(4, "Supriya");
9 | Student s2 = new Student(2, "Thaku Amit Singh");
10 | Student s3 = new Student(3, "Muthu");
11 | Student s4 = new Student(1, "Darshan");
12 |
13 | List arrayList = new ArrayList();
14 | arrayList.add(s1);
15 | arrayList.add(s2);
16 | arrayList.add(s3);
17 | arrayList.add(s4);
18 | System.out.println(arrayList);
19 | // Collections.sort(arrayList); // Comparable
20 | // Collections.sort(arrayList, new SortByID());
21 | // Collections.sort(arrayList, new SortByName());
22 | // Collections.sort(arrayList, new SortByIDDesc());
23 | Collections.sort(arrayList, new SortByNameDesc());
24 | System.out.println(arrayList);
25 |
26 |
27 | }
28 | }
29 |
30 | class SortByName implements Comparator {
31 | @Override
32 | public int compare(Student o1, Student o2) {
33 | return o1.getName().compareTo(o2.getName());
34 | }
35 | }
36 |
37 | class SortByNameDesc implements Comparator {
38 | @Override
39 | public int compare(Student o1, Student o2) {
40 | return o2.getName().compareTo(o1.getName());
41 | }
42 | }
43 |
44 | class SortByID implements Comparator {
45 | @Override
46 | public int compare(Student o1, Student o2) {
47 | return Integer.compare(o1.getId(), o2.getId());
48 | }
49 | }
50 |
51 | class SortByIDDesc implements Comparator {
52 | @Override
53 | public int compare(Student o1, Student o2) {
54 | return Integer.compare(o2.getId(), o1.getId());
55 | }
56 | }
57 |
58 |
59 | //class Student implements Comparable {
60 | class Student {
61 | private Integer id;
62 | private String name;
63 |
64 | public Student(Integer id, String name) {
65 | this.id = id;
66 | this.name = name;
67 | }
68 |
69 | public Integer getId() {
70 | return id;
71 | }
72 |
73 | public void setId(Integer id) {
74 | this.id = id;
75 | }
76 |
77 | public String getName() {
78 | return name;
79 | }
80 |
81 | public void setName(String name) {
82 | this.name = name;
83 | }
84 |
85 | @Override
86 | public String toString() {
87 | return "Student{" +
88 | "id=" + id +
89 | ", name='" + name + '\'' +
90 | '}';
91 | }
92 |
93 |
94 | // @Override
95 | // public int compareTo(Student another) {
96 | // return Integer.compare(this.id, another.id);
97 | // }
98 | //
99 | // @Override
100 | // public int compareTo(Student another) {
101 | // return CharSequence.compare(this.name, another.name);
102 | // }
103 | }
104 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab239.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collections;
5 | import java.util.LinkedList;
6 | import java.util.List;
7 |
8 | public class Lab239 {
9 | public static void main(String[] args) {
10 | ArrayList marks = new ArrayList();
11 | marks.add(14);
12 | marks.add(98);
13 | marks.add(10);
14 | marks.add(99);
15 | Collections.sort(marks); // Natural Sorting
16 | System.out.println(marks);
17 |
18 | ArrayList names = new ArrayList();
19 | names.add("Pramod");
20 | names.add("Amit");
21 | names.add("Dutta");
22 | names.add("Lukcy");
23 | Collections.sort(names); // A,D,L,P // Natural Sorting First Alpha
24 | System.out.println(names);
25 |
26 |
27 |
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab240.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | public class Lab240 {
4 | public static void main(String[] args) {
5 | Person p1 = new Person("Pramod","KA");
6 | Person p2 = new Person("Lucky","New Delhi");
7 | System.out.println(p1);
8 | System.out.println(p2);
9 | }
10 | }
11 |
12 | class Person extends Object{
13 | String name;
14 | String address;
15 |
16 | public Person(String name, String address) {
17 | this.name = name;
18 | this.address = address;
19 | }
20 |
21 | @Override
22 | public String toString() {
23 | return "ID ->" + name + " , Address -> " + address;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab241.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.HashSet;
4 | import java.util.LinkedHashSet;
5 | import java.util.Set;
6 | import java.util.TreeSet;
7 |
8 | public class Lab241 {
9 | public static void main(String[] args) {
10 | // List - > Duplicate Allows
11 | // Set -> Doesn't allow Duplicate
12 | Set hd = new HashSet();
13 | Set lhs = new LinkedHashSet();
14 | Set ts = new TreeSet();
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab242.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.*;
4 |
5 | public class Lab242 {
6 | public static void main(String[] args) {
7 | // List - > Duplicate Allows
8 | // Set -> Doesn't allow Duplicate
9 | Set hs = new HashSet(); // Hashing mechanism to store the element, no order
10 | hs.add("Apple");
11 | hs.add("Orange");
12 | hs.add("WaterMelon");
13 | hs.add("WaterMelon");
14 | hs.add(null);
15 | System.out.println(hs);
16 |
17 | Set lhs = new LinkedHashSet(); // LinkedList mechanism to store the element, order will maintain
18 | lhs.add("Apple");
19 | lhs.add("apple");
20 | lhs.add("Orange");
21 | lhs.add("WaterMelon");
22 | lhs.add(null);
23 | System.out.println(lhs);
24 | System.out.println(lhs.isEmpty());
25 | System.out.println(lhs.contains("Apple"));
26 | System.out.println(lhs.size());
27 |
28 |
29 | Set ts = new TreeSet(); // Black and Red Tree mechanism to store the element, order will maintain
30 | ts.add("Dapple");
31 | ts.add("Apple");
32 | ts.add("Orange");
33 | ts.add("Orange");
34 | ts.add("WaterMelon");
35 | // ts.add(null); # Can we sorting with null?
36 | System.out.println(ts);
37 |
38 |
39 | for (Object s : ts) {
40 | System.out.println(s);
41 | }
42 |
43 | Iterator it = ts.iterator();
44 | while (it.hasNext()) {
45 | System.out.println(it.next());
46 | }
47 |
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab243.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.PriorityQueue;
4 |
5 | public class Lab243 {
6 | public static void main(String[] args) {
7 | // Queue - < 1% in Automation
8 | //
9 | PriorityQueue pq= new PriorityQueue();
10 | pq.offer("1"); // add
11 | pq.offer("3");
12 | pq.offer("2");
13 | pq.offer("4");
14 | System.out.println(pq);
15 | System.out.println(pq.peek());
16 | System.out.println(pq.poll());
17 | System.out.println(pq);
18 |
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab244.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 | //Iterator later
3 |
4 | import java.util.*;
5 |
6 | public class Lab244 {
7 | public static void main(String[] args) {
8 | // Map - key and value pair
9 | // name:pramod, roll:31, phone:9876543210
10 | Map m1 = new HashMap();
11 | // Map m1 = new LinkedHashMap();
12 | // Map m1 = new TreeMap();
13 | m1.put("name","pramod");
14 | m1.put("rollNo",123);
15 | m1.put("phone",98765432);
16 | System.out.println(m1);
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab245.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class Lab245 {
7 | public static void main(String[] args) {
8 | Map map = new HashMap();
9 | map.put("id",1);
10 | map.put("id2",2);
11 | map.put("id3",34);
12 | map.put("id4",null);
13 | map.put("id5",null);
14 | // map.put(null,100);
15 | map.put(null,101);
16 | // map.put("id5","pramod");
17 | System.out.println(map);
18 | System.out.println(map.size());
19 | System.out.println(map.isEmpty());
20 | System.out.println(map.containsKey("id2"));
21 | System.out.println(map.containsValue(34));
22 | System.out.println(map.containsValue(99));
23 | System.out.println(map.keySet());
24 | System.out.println(map.values());
25 | System.out.println(map.get("id3"));
26 |
27 | System.out.println(" --- ");
28 |
29 | // How to iterate over all the elements in the map
30 | for(Map.Entry item: map.entrySet()){
31 | System.out.println(item.getKey() + " -> "+ item.getValue());
32 | }
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab246.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.*;
4 |
5 | public class Lab246 {
6 | public static void main(String[] args) {
7 | Hashtable ht1 = new Hashtable<>();
8 | // Map
9 | // null
10 | // Synchronised
11 | // Slow
12 | // Legacy Class
13 |
14 | ht1.put(1, "one");
15 | ht1.put(2, "two");
16 | ht1.put(3, "three");
17 |
18 |
19 | //
20 | Enumeration e = ht1.keys();
21 | while (e.hasMoreElements()){
22 | System.out.println(ht1.get(e.nextElement()));
23 | }
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab247.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.HashMap;
4 | import java.util.Hashtable;
5 | import java.util.Set;
6 |
7 | public class Lab247 {
8 | public static void main(String[] args) {
9 |
10 | //// Hashtable ht1 = new Hashtable<>();
11 | //// ht1.put(1, "one");
12 | //// ht1.put(null, "one"); // java.lang.NullPointerException
13 | //// //ht1.put("one", "one");
14 | //
15 | // HashMap h1 = new HashMap();
16 | // h1.put(null,"dasda");
17 |
18 | // Set fruits = new HashSet();
19 | // fruits.add("Apple");
20 | // fruits.add("Orange");
21 | // fruits.add("apple");
22 | // fruits.add("Water Melon");
23 | //// fruits.add(123);
24 |
25 |
26 |
27 |
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/aug/ex_24082024/Lab248.java:
--------------------------------------------------------------------------------
1 | package aug.ex_24082024;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class Lab248 {
7 | public static void main(String[] args) {
8 | // Generic - < 2%, very rare concept, rarly used also
9 | List