├── .gitignore ├── .vscode └── launch.json ├── AIDSIIB ├── CR.class ├── GoodStudents.class ├── Subjects.class └── batches │ ├── Batch1.class │ └── Batch2.class ├── Arrays ├── ComArray.java ├── ComArraym.java ├── ConsoleExam.java ├── IterateArray.java ├── MultiDimArray.java ├── Typcast.java └── enhanced_for_loop.java ├── Control Statements ├── Conditional Statements │ ├── Conditional.java │ ├── ConditionalScanner.java │ ├── README.md │ └── SwitchCase.java ├── Jumping Statements │ └── README.md ├── Looping Statments │ ├── DoWhileLoop.java │ ├── ForLoop.java │ ├── README.md │ └── WhileLoop.java └── README.md ├── ExceptionHandling ├── Exceptionhandling notes.pptx ├── checkedexcep │ ├── ChekdExcep.class │ └── ChekdExcep.java ├── runtimee │ ├── ArithmeticE.class │ ├── ArithmeticE.java │ ├── ArithmeticMain.java │ ├── DefExcepHandler.class │ ├── DefExcepHandler.java │ ├── TryWithResourcess.class │ └── TryWithResourcess.java └── userdefinedexcep │ ├── LAttend.class │ └── LAttend.java ├── Inheritance ├── Bicycle.class ├── Bicycle.java ├── ElectricBike.class ├── Flight.class ├── Hierarchical.class ├── Hierarchical.java ├── Motorbike.class ├── MultipleInh.class ├── MultipleInh.java ├── SpiderMan.class ├── Strength.class ├── TranspMul.class └── TranspMul.java ├── README.md ├── Strings ├── Comparision.java ├── Concatenate.java ├── String Tokenizers │ ├── StringFirst.java │ ├── StringSecond.java │ └── StringThird.java ├── StringBuff.class ├── StringBuff.java ├── StringBuil.class ├── StringBuil.java ├── StringExam.java └── Stringcomp.java ├── ThreadsExample ├── MTable.class ├── MTable.java ├── MulTable.class ├── Multi.class ├── Multi.java └── MultiThreadDemo.class ├── arithmeticop ├── Addition.class └── Subtraction.class ├── basics ├── ArithmeticOp.java ├── ArmstrongImpl.java ├── FactImpl.java ├── HelloWorld.java ├── InputMethods.java ├── NarrowCastExample.java ├── Primitive.java ├── Strings.java ├── StudentImpl.java ├── TypCast.java ├── controlstatements │ ├── EnhancedFor.java │ ├── Ifstmt.java │ ├── NestedIf.java │ ├── SwitchCase.java │ └── WhileExam.java ├── datatype │ ├── Datatype.java │ ├── NarrowCastExample.java │ └── TypeConv.java └── variables │ ├── Cricketer.java │ ├── CricketerImpl.java │ ├── InstanceVar.java │ └── StaticVar.java ├── finalkeyword └── FinExam.java ├── inheritance ├── FavSuperHero.class ├── FavSuperHero.java ├── IronMan.class ├── IronMan.java ├── SuperHero.class ├── SuperHero.java └── movies │ ├── ActionMovie.class │ ├── ActionMovie.java │ ├── Movie.class │ ├── Movie.java │ ├── MovieImpl.class │ └── MovieImpl.java ├── method overloading and method overriding ├── Area.class ├── Area.java ├── Overrid.class ├── Overrid.java ├── Rectangle.class └── Shape.class ├── notes ├── Arrays.pptx ├── Control statements.pptx ├── JP COURSE FILE-converted.pdf ├── Java Type Casting.pptx ├── Packageslatest.pptx ├── String Handling.pptx ├── StringTokenizer.pptx ├── intro-2.pptx ├── java intro.pptx └── operators,expressions,control stmts.pptx ├── packageprgms ├── A.java ├── AddSubImpl.java ├── Armstrong.java ├── B.java ├── C.java ├── CR.java ├── Factorial.java ├── JavaLab.java ├── StudentImpl.java ├── Subjects.java ├── Tokenize.java ├── Tokenn.java ├── TribonacciSeries.java ├── WordCount.java ├── Wrapper.java └── classADB.java ├── packageprograms ├── AIDSBPACKAGE PROGRAMS │ ├── Batch1.java │ ├── Batch2.java │ ├── CR.java │ └── GoodStudents.java └── ARITHMETICPROGRAMS │ ├── Addition.java │ └── Subtraction.java ├── same └── A.class ├── superuses ├── Dream.class ├── DreamImpl.class ├── DreamImpl.java ├── EthicalHacker.class ├── Job.class ├── Person.class ├── SuperImpl.class └── SuperImpl.java └── tokenize └── Tokenn.class /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "type": "java", 5 | "name": "WhileExam", 6 | "request": "launch", 7 | "mainClass": "basics.controlstatements.WhileExam", 8 | "projectName": "OOP-using-Java_b9476530" 9 | }, 10 | { 11 | "type": "java", 12 | "name": "SwitchCase", 13 | "request": "launch", 14 | "mainClass": "basics.controlstatements.SwitchCase", 15 | "projectName": "OOP-using-Java_b9476530" 16 | }, 17 | { 18 | "type": "java", 19 | "name": "Datatype", 20 | "request": "launch", 21 | "mainClass": "basics.datatype.Datatype", 22 | "projectName": "OOP-using-Java_b9476530" 23 | }, 24 | { 25 | "type": "java", 26 | "name": "CricketerImpl", 27 | "request": "launch", 28 | "mainClass": "basics.variables.CricketerImpl", 29 | "projectName": "OOP-using-Java_b9476530" 30 | }, 31 | { 32 | "type": "java", 33 | "name": "InstanceVar", 34 | "request": "launch", 35 | "mainClass": "basics.variables.InstanceVar", 36 | "projectName": "OOP-using-Java_b9476530" 37 | }, 38 | { 39 | "type": "java", 40 | "name": "NestedIf", 41 | "request": "launch", 42 | "mainClass": "basics.controlstatements.NestedIf", 43 | "projectName": "OOP-using-Java_b9476530" 44 | }, 45 | { 46 | "type": "java", 47 | "name": "Ifstmt", 48 | "request": "launch", 49 | "mainClass": "basics.controlstatements.Ifstmt", 50 | "projectName": "OOP-using-Java_b9476530" 51 | }, 52 | { 53 | "type": "java", 54 | "name": "NarrowCastExample", 55 | "request": "launch", 56 | "mainClass": "basics.NarrowCastExample", 57 | "projectName": "OOP-using-Java_b9476530" 58 | }, 59 | { 60 | "type": "java", 61 | "name": "TypeConv", 62 | "request": "launch", 63 | "mainClass": "basics.TypeConv", 64 | "projectName": "OOP-using-Java_b9476530" 65 | }, 66 | { 67 | "type": "java", 68 | "name": "ArmstrongImpl", 69 | "request": "launch", 70 | "mainClass": "basics.ArmstrongImpl", 71 | "projectName": "OOP-using-Java_b9476530" 72 | }, 73 | { 74 | "type": "java", 75 | "name": "FactImpl", 76 | "request": "launch", 77 | "mainClass": "basics.FactImpl", 78 | "projectName": "OOP-using-Java_b9476530" 79 | }, 80 | { 81 | "type": "java", 82 | "name": "StudentImpl", 83 | "request": "launch", 84 | "mainClass": "basics.StudentImpl", 85 | "projectName": "OOP-using-Java_b9476530" 86 | }, 87 | { 88 | "type": "java", 89 | "name": "ArithmeticOp", 90 | "request": "launch", 91 | "mainClass": "basics.ArithmeticOp", 92 | "projectName": "OOP-using-Java_b9476530" 93 | }, 94 | { 95 | "name": "gcc.exe - Build and debug active file", 96 | "type": "cppdbg", 97 | "request": "launch", 98 | "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", 99 | "args": [], 100 | "stopAtEntry": false, 101 | "cwd": "${fileDirname}", 102 | "environment": [], 103 | "externalConsole": true, 104 | "MIMode": "gdb", 105 | "miDebuggerPath": "E:\\CodeBlocks\\MinGW\\bin\\gdb.exe", 106 | "setupCommands": [ 107 | { 108 | "description": "Enable pretty-printing for gdb", 109 | "text": "-enable-pretty-printing", 110 | "ignoreFailures": true 111 | } 112 | ], 113 | "preLaunchTask": "C/C++: gcc.exe build active file" 114 | }, 115 | { 116 | "name": "gcc build & run active file", 117 | "type": "cppdbg", 118 | "request": "launch", 119 | "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", 120 | "args": [], 121 | "stopAtEntry": false, 122 | "cwd": "${fileDirname}", 123 | "environment": [], 124 | "externalConsole": false, 125 | "MIMode": "gdb", 126 | "miDebuggerPath": "E:\\CodeBlocks\\MinGW\\bin\\gdb.exe", 127 | "setupCommands": [ 128 | { 129 | "description": "Enable pretty-printing for gdb", 130 | "text": "-enable-pretty-printing", 131 | "ignoreFailures": true 132 | } 133 | ], 134 | "preLaunchTask": "gcc build & run active file" 135 | } 136 | ] 137 | } -------------------------------------------------------------------------------- /AIDSIIB/CR.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/AIDSIIB/CR.class -------------------------------------------------------------------------------- /AIDSIIB/GoodStudents.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/AIDSIIB/GoodStudents.class -------------------------------------------------------------------------------- /AIDSIIB/Subjects.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/AIDSIIB/Subjects.class -------------------------------------------------------------------------------- /AIDSIIB/batches/Batch1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/AIDSIIB/batches/Batch1.class -------------------------------------------------------------------------------- /AIDSIIB/batches/Batch2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/AIDSIIB/batches/Batch2.class -------------------------------------------------------------------------------- /Arrays/ComArray.java: -------------------------------------------------------------------------------- 1 | public class ComArray{ 2 | int[] arr3={4,7,3,9,2}; 3 | public static void main(String[] args) { 4 | /*common array element*/ 5 | int[] arr1={4,7,3,9,2}; 6 | int[] arr2={3,2,12,9,40,32,4}; 7 | for(int i=0;iarr[i]) 9 | min=arr[i]; 10 | System.out.println(min); 11 | 12 | } 13 | public static void main(String[] args){ 14 | int a[]={33,3,4,5}; 15 | min(a); 16 | } 17 | } -------------------------------------------------------------------------------- /Arrays/ConsoleExam.java: -------------------------------------------------------------------------------- 1 | import java.io.Console; 2 | /** 3 | System.console() returns null if your application is not run in a terminal (though you can handle this in your application 4 | secure password entry (hard to do cross-platform) 5 | synchronisation (multiple threads can prompt for input and Console will queue them up nicely, whereas if you used System.in/out then all of the prompts would appear simultaneously). 6 | 7 | */ 8 | class ConsoleExam{ 9 | public static void main(String[] args) { 10 | System.out.println("using console"); 11 | Console con=System.console(); 12 | if(con!=null){ 13 | con.printf("enter your name"); 14 | String name=con.readLine(); 15 | con.printf("Hello,%s!%n",name); 16 | }else{ 17 | System.out.println("console not available"); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Arrays/IterateArray.java: -------------------------------------------------------------------------------- 1 | class IterateArray{ 2 | public static void main(String[] ar){ 3 | int[] arr={1,2,4,5,6,7}; 4 | ComArray co=new ComArray(); 5 | for(int l:co.arr3){ 6 | System.out.println(l); 7 | } 8 | 9 | ComArray.main(null); 10 | System.out.println("elements are"); 11 | //array.length property tells the total elements in array 12 | for(int i=0;i num2 && num1 > num3) { 7 | System.out.printf(" %d is Greater", num1); 8 | } else if (num2 > num1 && num2 > num3) { 9 | System.out.printf(" %d is Greater", num2); 10 | } else { 11 | System.out.printf(" %d is Greater", num3); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Control Statements/Conditional Statements/ConditionalScanner.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class ConditionalScanner { 4 | public static void main(String[] args) { 5 | Scanner input = new Scanner(System.in); 6 | System.out.println("What is your Name? "); 7 | String name = input.next(); 8 | System.out.printf("HI %s ", name); 9 | System.out.println("Please Enter Number 1: "); 10 | int num1 = input.nextInt(); 11 | System.out.println("Please Enter Number 2: "); 12 | int num2 = input.nextInt(); 13 | System.out.println("Please Enter Number 3: "); 14 | int num3 = input.nextInt(); 15 | if (num1 > num2 && num1 > num3) { 16 | System.out.printf("%d is Greatest", num1); 17 | } else if (num2 > num1 && num2 > num3) { 18 | System.out.printf("%d is Greatest", num2); 19 | } else { 20 | System.out.printf("%d is Greatest", num3); 21 | } 22 | input.close(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Control Statements/Conditional Statements/README.md: -------------------------------------------------------------------------------- 1 | # Java Conditional Statements. 2 | 3 | In Java programming, conditional statements are used to perform different actions based on different conditions. There are mainly three types of conditional statements in Java: `if`, `else if`, and `else`. 4 | 5 | ## 1. `if` Statement 6 | 7 | The `if` statement checks a condition and executes a block of code if the condition is true. 8 | 9 | ### Syntax: 10 | ```java 11 | if (condition) { 12 | // Code to be executed if condition is true 13 | } 14 | 15 | ## 2. `else if` Statement 16 | 17 | The `else if` statement allows you to check multiple conditions after the initial `if` statement. If the first `if` condition is false, it evaluates the next condition. 18 | 19 | ### Syntax: 20 | ```java 21 | else if (condition) { 22 | // Code to be executed if condition is true 23 | } 24 | 25 | ## 3. `else` Statement 26 | 27 | The `else` statement is used to execute a block of code if none of the preceding conditions are true. 28 | 29 | ### Syntax: 30 | ```java 31 | else { 32 | // Code to be executed if no condition is true 33 | } 34 | -------------------------------------------------------------------------------- /Control Statements/Conditional Statements/SwitchCase.java: -------------------------------------------------------------------------------- 1 | public class SwitchCase { 2 | public static void main(String[] args) { 3 | int choice = 2; 4 | 5 | switch (choice) { 6 | case 1: 7 | System.out.println("You chose option 1"); 8 | break; 9 | case 2: 10 | System.out.println("You chose option 2"); 11 | break; 12 | case 3: 13 | System.out.println("You chose option 3"); 14 | break; 15 | default: 16 | System.out.println("Invalid choice"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Control Statements/Jumping Statements/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Control Statements/Jumping Statements/README.md -------------------------------------------------------------------------------- /Control Statements/Looping Statments/DoWhileLoop.java: -------------------------------------------------------------------------------- 1 | public class DoWhileLoop { 2 | public static void main(String[] args) { 3 | int i = 10; 4 | do { // This block will execute first before checking the condition. 5 | System.out.println("This is do Block"); 6 | } while (i != 10); // Condition becomes False. 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Control Statements/Looping Statments/ForLoop.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class ForLoop { 4 | public static void main(String[] args) { 5 | Scanner input = new Scanner(System.in); 6 | System.out.println("Enter a number for which you want a table: "); 7 | int number = input.nextInt(); 8 | for (int i = 1; i <= 10; i++) { 9 | System.out.println(number + "*" + i + "=" + number * i); 10 | } 11 | input.close(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Control Statements/Looping Statments/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Java Looping Statements 3 | 4 | In Java, looping statements are used to execute a block of code repeatedly based on a specified condition. There are mainly three types of looping statements in Java: `for`, `while`, and `do-while`. 5 | 6 | 7 | ## 1. `for` Loop 8 | 9 | The `for` loop is used when the number of iterations is known beforehand. 10 | 11 | ### Syntax: 12 | ```java 13 | for (initialization; condition; update) { 14 | // Code to be executed 15 | } 16 | ``` 17 | 18 | ### Example: 19 | ```java 20 | for (int i = 1; i <= 10; i++) { 21 | System.out.println(number + "*" + i + "=" + number * i); 22 | } 23 | ``` 24 | 25 | ## 2. `while` Loop 26 | 27 | The `while` loop is used when the number of iterations is not known beforehand, and the loop continues as long as a specified condition is true. 28 | 29 | ### Syntax: 30 | ```java 31 | while (condition) { 32 | // Code to be executed 33 | } 34 | ``` 35 | 36 | ### Example: 37 | ```java 38 | int i = 1; 39 | while (i <= 10) { 40 | System.out.println(number + "*" + i + "=" + number * i); 41 | i += 1; 42 | } 43 | ``` 44 | 45 | ## 3. `do-while` Loop 46 | 47 | The `do-while` loop is similar to the `while` loop, but the condition is checked after executing the code block, so it always executes at least once. 48 | 49 | ### Syntax: 50 | ```java 51 | do { 52 | // Code to be executed 53 | } while (condition); 54 | ``` 55 | 56 | ### Example: 57 | ```java 58 | int i = 1; 59 | do { 60 | System.out.println("This is Do block: "); 61 | i++; 62 | } while (i <= 10); 63 | ``` 64 | 65 | These looping statements provide flexibility in controlling the flow of execution in Java programs and are essential for repetitive tasks. 66 | ``` 67 | -------------------------------------------------------------------------------- /Control Statements/Looping Statments/WhileLoop.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class WhileLoop { 4 | public static void main(String[] args) { 5 | Scanner input = new Scanner(System.in); 6 | System.out.println("Enter a number for which you want a table: "); 7 | int number = input.nextInt(); 8 | int i = 1; 9 | while (i <= 10) { 10 | System.out.println(number + "*" + i + "=" + number * i); 11 | i += 1; 12 | } 13 | input.close(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Control Statements/README.md: -------------------------------------------------------------------------------- 1 | In Java, there are generally three types of control statements: 2 | 3 | Control statements are programming constructs that dictate the flow of execution within a program. They allow you to make decisions, repeat blocks of code, and alter the normal sequence of program execution. In essence, control statements enable you to control the flow of your program based on various conditions and requirements# Java Control Statements 4 | 5 | ## Selection Statements/Conditional Statements 6 | 7 | Conditional statements are used to make decisions based on certain conditions. 8 | 9 | - **if statement** 10 | - **if-else statement** 11 | - **if-else if-else statement** (also known as nested if-else) 12 | - **switch statement** 13 | 14 | ## Looping Statements (Iteration) 15 | 16 | Iteration statements are used to repeatedly execute a block of code. 17 | 18 | - **for loop** 19 | - **while loop** 20 | - **do-while loop** 21 | 22 | ## Jump Statements 23 | 24 | Jumping statements are used to alter the normal flow of control. 25 | 26 | - **break statement** 27 | - **continue statement** 28 | - **return statement** 29 | - **throw statement** 30 | 31 | These control statements provide various ways to control the flow of execution in Java programs. 32 | -------------------------------------------------------------------------------- /ExceptionHandling/Exceptionhandling notes.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ExceptionHandling/Exceptionhandling notes.pptx -------------------------------------------------------------------------------- /ExceptionHandling/checkedexcep/ChekdExcep.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ExceptionHandling/checkedexcep/ChekdExcep.class -------------------------------------------------------------------------------- /ExceptionHandling/checkedexcep/ChekdExcep.java: -------------------------------------------------------------------------------- 1 | public class ChekdExcep { 2 | 3 | public static void main(String[] args) { 4 | String className = "ChekdExcep"; 5 | 6 | try { 7 | // Attempting to load the class dynamically 8 | Class clz = Class.forName(className); 9 | System.out.println("Class loaded successfully: " + clz.getName()); 10 | } catch (ClassNotFoundException e) { 11 | System.err.println("Class not found: " + className); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ExceptionHandling/runtimee/ArithmeticE.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ExceptionHandling/runtimee/ArithmeticE.class -------------------------------------------------------------------------------- /ExceptionHandling/runtimee/ArithmeticE.java: -------------------------------------------------------------------------------- 1 | class ArithmeticE{ 2 | public static void main(String[] args){ 3 | try{ 4 | int num=10/0; 5 | System.out.println(num); 6 | } 7 | catch(ArithmeticException ae){ 8 | System.out.println(ae); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /ExceptionHandling/runtimee/ArithmeticMain.java: -------------------------------------------------------------------------------- 1 | class ArithmeticMain{ 2 | public static void main(String[] args){ 3 | try{ 4 | int num=10/0; 5 | System.out.println(num); 6 | } 7 | catch(Exception e){ 8 | System.out.println("parent class exceptionhandles"+e); 9 | } 10 | catch(ArithmeticException ae){ 11 | System.out.println(ae); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /ExceptionHandling/runtimee/DefExcepHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ExceptionHandling/runtimee/DefExcepHandler.class -------------------------------------------------------------------------------- /ExceptionHandling/runtimee/DefExcepHandler.java: -------------------------------------------------------------------------------- 1 | class DefExcepHandler{ 2 | public static void main(String[] args){ 3 | 4 | 5 | int data=50/0; 6 | System.out.println(data); 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /ExceptionHandling/runtimee/TryWithResourcess.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ExceptionHandling/runtimee/TryWithResourcess.class -------------------------------------------------------------------------------- /ExceptionHandling/runtimee/TryWithResourcess.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class TryWithResourcess { 3 | public static void main(String[] args) { 4 | try (Scanner sc = new Scanner(System.in)) { 5 | System.out.print("Enter nr: "); 6 | int nr = sc.nextInt(); 7 | 8 | System.out.print("Enter dr: "); 9 | int dr = sc.nextInt(); 10 | 11 | 12 | int result = nr/dr; 13 | System.out.println("Result of division: " + result); 14 | 15 | } catch (ArithmeticException e) { 16 | System.out.println("Error: Division by zero is not allowed."); 17 | } catch (Exception e) { 18 | System.out.println("Error: " + e.getMessage()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ExceptionHandling/userdefinedexcep/LAttend.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ExceptionHandling/userdefinedexcep/LAttend.class -------------------------------------------------------------------------------- /ExceptionHandling/userdefinedexcep/LAttend.java: -------------------------------------------------------------------------------- 1 | import java .io.*; 2 | class LAttend extends Exception{ 3 | LAttend(String str){ 4 | super(str); 5 | } 6 | public static void main(String[] args){ 7 | try{ 8 | BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); 9 | System.out.println("enter the held classes"); 10 | double h=Double.parseDouble(br.readLine()); 11 | System.out.println("enter the attended classes"); 12 | double at=Double.parseDouble(br.readLine()); 13 | double p=(at/h)*100; 14 | System.out.println("percentage is "+p); 15 | if(p<75){ 16 | LAttend lat=new LAttend("You are not allowed for JAVA LAB exam"); 17 | throw lat; 18 | } 19 | }catch(LAttend la){ 20 | System.out.println(la); 21 | } 22 | catch(IOException ie){ 23 | System.out.println(ie); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Inheritance/Bicycle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/Bicycle.class -------------------------------------------------------------------------------- /Inheritance/Bicycle.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/Bicycle.java -------------------------------------------------------------------------------- /Inheritance/ElectricBike.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/ElectricBike.class -------------------------------------------------------------------------------- /Inheritance/Flight.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/Flight.class -------------------------------------------------------------------------------- /Inheritance/Hierarchical.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/Hierarchical.class -------------------------------------------------------------------------------- /Inheritance/Hierarchical.java: -------------------------------------------------------------------------------- 1 | class SuperHero { 2 | String name; 3 | String power; 4 | 5 | public SuperHero(String name, String power) { 6 | this.name = name; 7 | this.power = power; 8 | } 9 | 10 | public void usePower() { 11 | System.out.println(name + " uses " + power); 12 | } 13 | } 14 | 15 | class IronMan extends SuperHero { 16 | public IronMan(String name) { 17 | super(name, " advanced technology"); 18 | } 19 | } 20 | 21 | class SpiderMan extends SuperHero { 22 | public SpiderMan(String name) { 23 | super(name, "web-slinging and spider-like abilities"); 24 | } 25 | } 26 | 27 | 28 | public class Hierarchical { 29 | public static void main(String[] args) { 30 | IronMan ironMan = new IronMan("Iron Man"); 31 | SpiderMan spiderMan = new SpiderMan("Spider Man"); 32 | 33 | ironMan.usePower(); 34 | spiderMan.usePower(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Inheritance/Motorbike.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/Motorbike.class -------------------------------------------------------------------------------- /Inheritance/MultipleInh.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/MultipleInh.class -------------------------------------------------------------------------------- /Inheritance/MultipleInh.java: -------------------------------------------------------------------------------- 1 | interface Flight { 2 | void fly(); 3 | } 4 | 5 | interface Strength { 6 | void superStrength(); 7 | } 8 | 9 | class SuperHero implements Flight, Strength { 10 | String name; 11 | 12 | public SuperHero(String name) { 13 | this.name = name; 14 | } 15 | 16 | @Override 17 | public void fly() { 18 | System.out.println(name + " flies through the sky!"); 19 | } 20 | 21 | @Override 22 | public void superStrength() { 23 | System.out.println(name + " demonstrates super strength!"); 24 | } 25 | 26 | public void useAbility() { 27 | System.out.println(name + " uses super abilities!"); 28 | } 29 | } 30 | 31 | 32 | public class MultipleInh { 33 | public static void main(String[] args) { 34 | SuperHero superman = new SuperHero("Superman"); 35 | superman.useAbility(); 36 | superman.fly(); 37 | superman.superStrength(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Inheritance/SpiderMan.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/SpiderMan.class -------------------------------------------------------------------------------- /Inheritance/Strength.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/Strength.class -------------------------------------------------------------------------------- /Inheritance/TranspMul.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Inheritance/TranspMul.class -------------------------------------------------------------------------------- /Inheritance/TranspMul.java: -------------------------------------------------------------------------------- 1 | // Base class for the simplest form of transportation 2 | class Bicycle { 3 | void displayFeatures() { 4 | System.out.println("Features: Pedals, Manual power"); 5 | } 6 | } 7 | 8 | // Inherits from Bicycle and adds an engine 9 | class Motorbike extends Bicycle { 10 | void displayFeatures() { 11 | super.displayFeatures(); // Display features of Bicycle 12 | System.out.println("Added feature by Motorbike: Engine"); 13 | } 14 | } 15 | 16 | // Inherits from Motorbike and integrates an electric motor 17 | class ElectricBike extends Motorbike { 18 | void displayFeatures() { 19 | super.displayFeatures(); // Display features of Motorbike 20 | System.out.println("New feature by ElectricBike: Electric motor and battery"); 21 | } 22 | } 23 | 24 | // Main class to test the inheritance 25 | class TranspMul { 26 | public static void main(String args[]) { 27 | ElectricBike myEbike = new ElectricBike(); 28 | myEbike.displayFeatures(); // Display the cumulative features of the evolution 29 | } 30 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java Programming 2 | This repository is focused on Core to Advanced Java Programming.It covers the OOP concepts, packages,Collections framework, Java Swings. 3 | ## Contributing 4 | 5 | Contributions are always welcome! 6 | 7 | - Create a personal fork of the project on Github.This will create a copy of this repository in your account. 8 | 9 | - Clone the fork on your local machine. Your remote repo on Github is called origin. 10 | 11 | ``` 12 | git clone "url u just copied" 13 | ``` 14 | 15 | - Make necessary changes and commit using 16 | ``` 17 | git add filename 18 | ``` 19 | ``` 20 | git commit -m "msg" 21 | ``` 22 | - Push your changes to github forked repository. 23 | ``` 24 | git push -u origin your-branch-name 25 | ``` 26 | - Submit your changes for a review 27 | ``` 28 | If you go to your repository on GitHub, you'll see a Compare & pull request button. Click on that button. 29 | ``` 30 | - Open a pull request 31 | -Soon I'll be merging all your changes into the main branch of this project. You will get a notification email once the changes have been merged. 32 | -------------------------------------------------------------------------------- /Strings/Comparision.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class Comparision{ 3 | public static void main(String[] ar){ 4 | Scanner sc=new Scanner(System.in); 5 | System.out.println("enter your subject"); 6 | String subj=sc.next(); 7 | String sch=new String("python"); 8 | if(subj.equals("java")){ 9 | System.out.println("patience is needed"); 10 | } 11 | else{ 12 | System.out.println("dont waste time"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Strings/Concatenate.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class Concatenate{ 3 | public static void main(String[] args){ 4 | String first="java"; 5 | String second="lab"; 6 | String complete=first.concat(second); 7 | System.out.println(complete); 8 | String name="james"; 9 | String lname="gosling"; 10 | String auth=name+lname; 11 | System.out.println(auth); 12 | } 13 | } -------------------------------------------------------------------------------- /Strings/String Tokenizers/StringFirst.java: -------------------------------------------------------------------------------- 1 | //Java Program using first Constructor(using Single parameter). 2 | 3 | import java.util.StringTokenizer; 4 | class StringFirst { 5 | public static void main(String[] args) { 6 | StringTokenizer st = new StringTokenizer("This statement is passed directly inside the class."); 7 | System.out.println("Tokens extracted from the string using StringTokenizer: "); 8 | while (st.hasMoreTokens()) { 9 | System.out.println(st.nextToken()); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Strings/String Tokenizers/StringSecond.java: -------------------------------------------------------------------------------- 1 | //Java Program using Second Constructor(using input string and delimiter). 2 | //Syntax: StringTokenizer(String str, String delim) 3 | 4 | import java.util.StringTokenizer; 5 | import java.util.Scanner; 6 | 7 | class StringSecond { 8 | public static void main(String[] args) { 9 | Scanner sc = new Scanner(System.in); 10 | System.out.println("Enter the string: "); 11 | String s1 = sc.nextLine(); 12 | StringTokenizer st = new StringTokenizer(s1," "); 13 | System.out.println("Tokens extracted from the string using StringTokenizer: "); 14 | while (st.hasMoreTokens()) { 15 | System.out.println(st.nextToken()); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Strings/String Tokenizers/StringThird.java: -------------------------------------------------------------------------------- 1 | //Java Program using Third Construtor. 2 | //Syntax: StringTokenizer(String str, String delim, boolean returnDelims) 3 | 4 | 5 | import java.util.StringTokenizer; 6 | import java.util.Scanner; 7 | 8 | class StringThird { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | System.out.println("Enter the string separated by commas: "); 12 | String s1 = sc.nextLine(); 13 | /*When we pass true as the third parameter to the StringTokenizer constructor, 14 | it indicates that the delimiters should be treated as tokens and included in the result.*/ 15 | StringTokenizer st = new StringTokenizer(s1, ",", true); 16 | 17 | System.out.println("Tokens extracted from the string using StringTokenizer: "); 18 | while (st.hasMoreTokens()) { 19 | System.out.println(st.nextToken()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Strings/StringBuff.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Strings/StringBuff.class -------------------------------------------------------------------------------- /Strings/StringBuff.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class StringBuff{ 3 | public static void main(String[] args){ 4 | Scanner sc=new Scanner(System.in); 5 | System.out.println("enter the string"); 6 | String s1=sc.next(); 7 | s1.concat("hey"); 8 | System.out.println("String after concatenation is "+s1); 9 | StringBuffer sb=new StringBuffer("hello"); 10 | sb.append("hi"); 11 | System.out.println("string after appending is "+sb); 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /Strings/StringBuil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/Strings/StringBuil.class -------------------------------------------------------------------------------- /Strings/StringBuil.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class StringBuil{ 3 | public static void main(String[] args){ 4 | Scanner sc=new Scanner(System.in); 5 | System.out.println("enter the string"); 6 | String s1=sc.next(); 7 | s1.concat("hey"); 8 | System.out.println("String after concatenation is "+s1); 9 | StringBuilder sb=new StringBuilder("hello"); 10 | sb.append("hi"); 11 | System.out.println("string after appending is "+sb); 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /Strings/StringExam.java: -------------------------------------------------------------------------------- 1 | class StringExam{ 2 | public static void main(String[] args){ 3 | String str="tonight"; 4 | System.out.println(str.indexOf('u')); 5 | System.out.println(str.indexOf('t',3)); 6 | String subString="ton"; 7 | System.out.println(str.indexOf(subString)); 8 | System.out.println(str.indexOf(subString,7)); 9 | } 10 | } -------------------------------------------------------------------------------- /Strings/Stringcomp.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class Stringcomp{ 3 | public static void main(String[] ar){ 4 | Scanner sc=new Scanner(System.in); 5 | System.out.println("enter your name:"); 6 | String nam=sc.nextLine(); 7 | if(nam.equals("java")){ 8 | System.out.println("good choice"); 9 | } 10 | else{ 11 | System.out.println("you have entered"+nam); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /ThreadsExample/MTable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ThreadsExample/MTable.class -------------------------------------------------------------------------------- /ThreadsExample/MTable.java: -------------------------------------------------------------------------------- 1 | class MTable { 2 | public static void main(String[] args){ 3 | MulTable t1=new MulTable(5); 4 | t1.start(); 5 | } 6 | } 7 | class MulTable extends Thread{ 8 | int num; 9 | MulTable(int n){ 10 | this.num=n; 11 | } 12 | public void run(){ 13 | for(int i=1;i<=10;i++){ 14 | System.out.println(num+"*"+i+"="+(num*i)); 15 | try{ 16 | Thread.sleep(400); 17 | } 18 | catch(Exception e){ 19 | e.printStackTrace(); 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /ThreadsExample/MulTable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ThreadsExample/MulTable.class -------------------------------------------------------------------------------- /ThreadsExample/Multi.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mssanamateen/OOP-using-Java/e7791accff59ce4a1f02431a85ad66a952cfb12b/ThreadsExample/Multi.class -------------------------------------------------------------------------------- /ThreadsExample/Multi.java: -------------------------------------------------------------------------------- 1 | class Multi{ 2 | public static void main(String[] args){ 3 | int n=4; 4 | for(int i=0;i=18){ 9 | System.out.println("You are allowed to vote"); 10 | } 11 | else{ 12 | System.out.println("You are not eligible"); 13 | } 14 | sc.close(); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /basics/controlstatements/NestedIf.java: -------------------------------------------------------------------------------- 1 | package basics.controlstatements; 2 | 3 | public class NestedIf { 4 | public static void main(String[] args){ 5 | java.util.Scanner sc=new java.util.Scanner(System.in); 6 | System.out.println("enter your favorite iconic character:"); 7 | String act=sc.nextLine(); 8 | if(act.equals("Iron Man")){ 9 | System.out.println("Great choice"); 10 | System.out.println("enter"+act+"real name"); 11 | String reall=sc.nextLine(); 12 | if(reall.equalsIgnoreCase("tony stark")){ 13 | System.out.println("Cool actor"); 14 | } 15 | }else{ 16 | System.out.println(act); 17 | } 18 | sc.close(); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /basics/controlstatements/SwitchCase.java: -------------------------------------------------------------------------------- 1 | package basics.controlstatements; 2 | import java.util.*; 3 | public class SwitchCase { 4 | public static void main(String[] args) { 5 | int a=4,b=2; 6 | Scanner sc=new Scanner(System.in); 7 | System.out.println("******"); 8 | System.out.println("*ARITHMETIC OPERATIONS***"); 9 | System.out.println("1. Add"); 10 | System.out.println("2. Sub"); 11 | System.out.println("3. Mul"); 12 | System.out.println("4. Div"); 13 | System.out.println("enter your choice"); 14 | int ch=sc.nextInt(); 15 | switch(ch){ 16 | case 1-> System.out.println("addition result is"+(a+b)); 17 | case 2-> System.out.println("subtraction result is"+(a-b)); 18 | case 3-> System.out.println("multiplication result is"+(a*b)); 19 | case 4-> System.out.println("division result is"+(a/b)); 20 | default -> System.out.println("give proper option"); 21 | } 22 | sc.close(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /basics/controlstatements/WhileExam.java: -------------------------------------------------------------------------------- 1 | package basics.controlstatements; 2 | import java.util.*; 3 | /** 4 | * Java program to accept input and store in arrays 5 | */ 6 | public class WhileExam { 7 | public static void main(String[] p){ 8 | Scanner sc=new Scanner(System.in); 9 | int i=0; 10 | System.out.println("enter the limit"); 11 | int n=sc.nextInt(); 12 | System.out.println("enter the marks"); 13 | int marks[]=new int[n]; 14 | while(i