├── Collections ├── ArrayList01.class └── ArrayList01.java ├── Day_01 ├── Example01 │ ├── BaiscMain.java │ ├── BasicMain.class │ ├── Employee.java │ └── Question.md └── Practice Questions │ └── 01 Question.md ├── Day_02 ├── Client.java ├── ClientMain.java └── Practice Questions │ └── 01 Question.md ├── Day_03 ├── Practice Questions │ └── 01 Questions.md ├── This_keyword.class └── This_keyword.java ├── Day_04 ├── Client.java ├── Encapsulation.java └── Practice Questions │ └── 01 Questions.md ├── Day_05 ├── Compile_Time_Polymorphism.class ├── Compile_Time_Polymorphism.java └── RunTimePolymorphism.java ├── Day_06 ├── Practice Questions │ ├── Question 1.md │ └── Question 2.md ├── Single_Array.class ├── Single_Array.java ├── UserInput.class └── UserInput.java ├── Day_07 ├── ExceptionHandling.class ├── ExceptionHandling1.class └── ExceptionHandling1.java ├── Day_08 ├── Bill.java ├── Customers.java ├── MainClass.java └── Orders.java ├── Day_09 ├── Employee_p4n.class ├── Employee_p4n.java └── Employee_p4nMain.java ├── Day_10 ├── EmployeeMain.java ├── Employees.java ├── Orders.java └── Polymorphism.java ├── Day_11 └── Single │ ├── BookPrice.java │ └── Books.java ├── Day_12 ├── FunctionWithArg.java ├── Function_01.java └── Function_With_Return_Type.java ├── Day_13 └── Employee.java ├── Day_14 ├── CreditCard.java └── CreditCardMain.java ├── Encapsulation ├── Employee.java ├── MainEmployee.java ├── StudentMain.java └── Students.java ├── ExceptionHandling └── Hospital.java ├── Inheritance ├── HierarchicalInheritance.java ├── Multilevelinheritance.java ├── MultipleInheritance.java ├── OtherExample │ ├── Child.java │ ├── MainClass.java │ └── Parent.java └── Singleinheritance.java ├── InterFace └── client.java ├── Java_String ├── Advance_Example.java ├── Basic_Example.class └── Basic_Example.java ├── LICENSE ├── Map └── Mapexample.java ├── README.md ├── Set ├── Set_Example01.class └── Set_Example01.java ├── Strings ├── StringBuilder1.java ├── String_Example01.class ├── String_Example01.java └── Stringbuffer_example.java ├── SuperKeyword └── customer.java └── Threading └── SingleThread.java /Collections/ArrayList01.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Collections/ArrayList01.class -------------------------------------------------------------------------------- /Collections/ArrayList01.java: -------------------------------------------------------------------------------- 1 | package Collections; 2 | import java.util.ArrayList; 3 | public class ArrayList01 { 4 | 5 | public static void main(String[] args) { 6 | 7 | // create a array list 8 | ArrayList data = new ArrayList(); 9 | 10 | // add data into array list 11 | data.add("Java"); 12 | data.add("Python"); 13 | data.add("C++"); 14 | data.add("C#"); 15 | data.add("Ruby"); 16 | 17 | // print array list 18 | 19 | System.out.println("Array List: " + data); 20 | 21 | // remove item from array list 22 | data.remove("C++"); 23 | 24 | System.out.println("Array List after removing C++: " + data); 25 | 26 | // remove item from array list using index 27 | data.remove(1); 28 | 29 | System.out.println("Array List after removing item at index 1: " + data); 30 | 31 | // get item from array list using index 32 | 33 | String item = data.get(1); 34 | System.out.println("Item at index 1: " + item); 35 | 36 | // set item at index 1 37 | data.set(1, "JavaScript"); 38 | 39 | System.out.println("Array List after setting item at index 1: " + data); 40 | 41 | // print using for loop 42 | 43 | System.out.println("Array List using for loop: "); 44 | 45 | for(String item1: data) { 46 | System.out.println(item1); 47 | } 48 | 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /Day_01/Example01/BaiscMain.java: -------------------------------------------------------------------------------- 1 | class BasicMain{ 2 | 3 | public static void main(String[] args){ 4 | 5 | // System.out.println("codeswithpankaj"); 6 | 7 | // create an object : 8 | 9 | // ClassName ObjectName = new ClassName() 10 | 11 | Employee emp = new Employee(); 12 | emp.get_info(); 13 | emp.get_salary(56000, 7); 14 | emp.get_salary(56000, 3); 15 | 16 | System.out.println("Your City Name is : "+emp.get_city()); 17 | System.out.println("Your height Name is : "+emp.get_height()); 18 | System.out.println("Your price Name is : "+emp.get_price()); 19 | System.out.println("this is result : "+emp.get_result(700,800)); 20 | 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Day_01/Example01/BasicMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_01/Example01/BasicMain.class -------------------------------------------------------------------------------- /Day_01/Example01/Employee.java: -------------------------------------------------------------------------------- 1 | public class Employee { 2 | 3 | 4 | 5 | 6 | // basic = without args. and without return type. 7 | void get_info(){ 8 | System.out.println("Employee Name : joy"); 9 | } 10 | // without args and with return type. 11 | 12 | int get_price(){ 13 | 14 | return 999; 15 | } 16 | 17 | String get_city(){ 18 | 19 | return "mumbai"; 20 | } 21 | 22 | float get_height(){ 23 | 24 | return 5.6f; 25 | } 26 | 27 | // without return type and with args. 28 | 29 | void get_salary(int salary,int leave){ 30 | int oneDaySalary = salary/30; 31 | int leave_amount = oneDaySalary*leave; 32 | int final_salary = salary - leave_amount; 33 | 34 | System.out.println("---------Salary---------------"); 35 | System.out.println("Monthly Salary : "+salary); 36 | System.out.println("leave : "+leave); 37 | System.out.println("leave amount : "+leave_amount); 38 | System.out.println("Pay Salary : "+final_salary); 39 | System.out.println("------------------------"); 40 | 41 | } 42 | 43 | // with return type and with args. 44 | 45 | int get_result(int number1,int number2){ 46 | 47 | int result = number1 + number2; 48 | 49 | return result; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Day_01/Example01/Question.md: -------------------------------------------------------------------------------- 1 | # 01 Salary System 2 | 3 | ```yaml 4 | 5 | -- input section 6 | 7 | Enter Employee Name = Joy 8 | Enter Employee ID = A001 9 | Enter Employee Salary (Monthly) = 10000/- 10 | Enter Leave (Days) = 7 11 | TDS % = 2 12 | Month = 3 13 | year = 2023 14 | 15 | -- out section 16 | Name : Joy 17 | EMP ID : A001 18 | Monthly Salary : 10,000/- 19 | CTC (Yearly Salary ) : 120,000/- 20 | Leave Amount : 2,258.06452/- 21 | TDS Amount : 200/- 22 | Final Pay Salary : 7,541.93548/- 23 | Date = March/2023 24 | 25 | 26 | ``` -------------------------------------------------------------------------------- /Day_01/Practice Questions/01 Question.md: -------------------------------------------------------------------------------- 1 | ### What will be the output of the below program? 2 | ```java 3 | 4 | class A 5 | { 6 | static int i; 7 | 8 | static 9 | { 10 | i = 100; 11 | 12 | System.out.println(1); 13 | } 14 | 15 | static void staticMethod() 16 | { 17 | System.out.println(i); 18 | 19 | System.out.println(2); 20 | } 21 | } 22 | 23 | public class B 24 | { 25 | static 26 | { 27 | System.out.println(3); 28 | } 29 | 30 | public static void main(String[] args) 31 | { 32 | System.out.println(4); 33 | 34 | System.out.println(A.i); 35 | 36 | A.staticMethod(); 37 | } 38 | } 39 | 40 | ``` 41 | -------------------------------------------------------------------------------- /Day_02/Client.java: -------------------------------------------------------------------------------- 1 | package Day_02; 2 | 3 | public class Client { 4 | 5 | String ClientName; 6 | 7 | Client(){ 8 | 9 | System.out.println("Joy Food Store"); 10 | 11 | } 12 | 13 | 14 | Client(String city,int price){ 15 | 16 | System.out.println("Client City "+city); 17 | System.out.println("Client Food "+price); 18 | 19 | } 20 | 21 | void getClientInfo(){ 22 | 23 | System.out.println("Client Name : "+ClientName); 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Day_02/ClientMain.java: -------------------------------------------------------------------------------- 1 | package Day_02; 2 | 3 | public class ClientMain { 4 | 5 | public static void main(String[] args) { 6 | 7 | // create a object of client class 8 | // className objectName = new className(); 9 | 10 | Client client = new Client(); 11 | client.ClientName = "joy"; 12 | client.getClientInfo(); 13 | client.ClientName = "Nishant"; 14 | client.getClientInfo(); 15 | 16 | Client client1 = new Client("mumbai",9800); 17 | Client client2 = new Client("Bhuj",5600); 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Day_02/Practice Questions/01 Question.md: -------------------------------------------------------------------------------- 1 | # Student Marksheet Program 2 | 3 | ### use topic 4 | 5 | 1. Class & Object 6 | 2. Methods 7 | 3. if else 8 | 4. variable 9 | 5. user input 10 | 6. Operator 11 | 12 | ```yaml 13 | 14 | ----- input section -----(user input) 15 | Enter Student Name : - Joy 16 | 1. JAVA - Marks = 80/100 17 | 2. C++ - Marks = 20/100 18 | 3. JSP - Marks = 80/100 19 | 4. Ruby - Marks = 40/100 20 | 5. C# - Marks = 10/100 21 | 22 | ----------output --------------- 23 | java = 80/100 24 | C++ = 20/100 F 25 | JSP = 80/100 26 | Ruby = 40/100 27 | C# = 10/100 F 28 | 29 | total = ? 30 | per% = ? 31 | Result = Fail (if student fail in single subject) 32 | ----- 33 | Grading System 34 | 80 - 100 = Grade A 35 | 60 - 80 = Grade B 36 | 40 - 60 = Grade C 37 | 30 - 40 = Grade D 38 | 0 - 30 Grade F 39 | 40 | ``` -------------------------------------------------------------------------------- /Day_03/Practice Questions/01 Questions.md: -------------------------------------------------------------------------------- 1 | # Age Calculator 2 | 3 | ```yaml 4 | --- Date of Birth 5 | Enter Birth Year : 2001 6 | Enter Birth Month : 11 7 | Enter Birth Day : 19 8 | 9 | --- Current Date 10 | Enter Birth Year : 2023 11 | Enter Birth Month : 7 12 | Enter Birth Day : 27 13 | 14 | ---output 15 | Age : 16 | 21 years 8 months 8 days 17 | or 260 months 8 days 18 | or 1131 weeks 3 days 19 | or 7,920 days 20 | 21 | 22 | 23 | ``` -------------------------------------------------------------------------------- /Day_03/This_keyword.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_03/This_keyword.class -------------------------------------------------------------------------------- /Day_03/This_keyword.java: -------------------------------------------------------------------------------- 1 | package Day_03; 2 | class This_keyword{ 3 | String name; 4 | int age; 5 | void set_value(String name , int age ){ 6 | 7 | this.name = name; 8 | this.age = age; 9 | } 10 | void get_value(){ 11 | 12 | System.out.println("your name is : "+name); 13 | System.out.println("your age is : "+age); 14 | 15 | } 16 | public static void main(String[] args) { 17 | This_keyword obj = new This_keyword(); 18 | obj.set_value("joy", 12); 19 | obj.get_value(); 20 | } 21 | } -------------------------------------------------------------------------------- /Day_04/Client.java: -------------------------------------------------------------------------------- 1 | package Day_04; 2 | 3 | public class Client { 4 | 5 | String ClientName; 6 | int ordersNo; 7 | float price; 8 | public Client(String ClientName, int ordersNo, float price) 9 | { 10 | this.ClientName = ClientName; 11 | this.ordersNo = ordersNo; 12 | this.price = price; 13 | } 14 | public String getClientName() { 15 | return ClientName; 16 | } 17 | public void setClientName(String ClientName) { 18 | this.ClientName = ClientName; 19 | } 20 | public int getOrdersNo() { 21 | return ordersNo; 22 | } 23 | public void setOrdersNo(int ordersNo) { 24 | this.ordersNo = ordersNo; 25 | } 26 | public float getPrice() { 27 | return price; 28 | } 29 | public void setPrice(float price) { 30 | this.price = price; 31 | } 32 | 33 | 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Day_04/Encapsulation.java: -------------------------------------------------------------------------------- 1 | package Day_04; 2 | 3 | /** 4 | * Encapsulation 5 | */ 6 | public class Encapsulation { 7 | 8 | public static void main(String[] args) { 9 | Client client = new Client("joy",101 , 1200.34f); 10 | String Client_name = client.getClientName(); 11 | int orders_No = client.getOrdersNo(); 12 | float price_p = client.getPrice(); 13 | 14 | System.out.println("Client Name : "+Client_name); 15 | System.out.println("Client Order No. : "+orders_No); 16 | System.out.println("Client Name price: "+price_p); 17 | 18 | client.setClientName("Rohit"); 19 | 20 | System.out.println("Client Name : "+client.getClientName()); 21 | System.out.println("Client Order No. : "+client.getOrdersNo()); 22 | System.out.println("Client Name price: "+client.getPrice()); 23 | 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /Day_04/Practice Questions/01 Questions.md: -------------------------------------------------------------------------------- 1 | # MCQ with password 2 | 3 | ```yaml 4 | Set your password : 5 | p4n@in 6 | Enter your Password : 7 | p4n 8 | wrong password ... try 2 more time out of 2 9 | p4n@ 10 | wrong password ... try 1 more time 1 11 | p4n@34 12 | wrong password ... try 0 more time 0 13 | note : user select right password 14 | then start MCQ EXAM... 15 | 16 | 17 | 1. Who invented Java Programming? 18 | 1. ) Guido van Rossum 19 | 2. ) James Gosling 20 | 3. ) Dennis Ritchie 21 | 4. ) Bjarne Stroustrup 22 | 23 | Select Answer 2 24 | 25 | wrong answer [ Try Next year ] 26 | 27 | Note :if select Right Answer 28 | ask 2nd Question ... 29 | 30 | 2. Which component is used to compile, debug and execute the java programs? 31 | 1. ) JRE 32 | 2. ) JIT 33 | 3. ) JDK 34 | 4. ) JVM 35 | 36 | Select Answer 2 ... con.. 37 | 38 | 39 | ``` -------------------------------------------------------------------------------- /Day_05/Compile_Time_Polymorphism.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_05/Compile_Time_Polymorphism.class -------------------------------------------------------------------------------- /Day_05/Compile_Time_Polymorphism.java: -------------------------------------------------------------------------------- 1 | package Day_05; 2 | 3 | public class Compile_Time_Polymorphism { 4 | 5 | void get_info(){ 6 | 7 | System.out.println("welcome to p4n"); 8 | 9 | } 10 | 11 | void get_info(String msg){ 12 | 13 | System.out.println("welcome : "+msg); 14 | 15 | } 16 | 17 | void get_info(int pin){ 18 | 19 | System.out.println("Pin ID : "+pin); 20 | 21 | } 22 | 23 | public static void main(String[] args) { 24 | Compile_Time_Polymorphism ctp = new Compile_Time_Polymorphism(); 25 | ctp.get_info(); 26 | ctp.get_info(306702); 27 | ctp.get_info("Welcome to CWP"); 28 | } 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Day_05/RunTimePolymorphism.java: -------------------------------------------------------------------------------- 1 | package Day_05; 2 | 3 | class client{ 4 | 5 | void order_info(){ 6 | System.out.println("order - 101"); 7 | System.out.println("order - 102"); 8 | System.out.println("order - 103"); 9 | } 10 | 11 | } 12 | 13 | class orders extends client{ 14 | 15 | void order_info(){ 16 | super.order_info(); 17 | System.out.println("Food"); 18 | System.out.println("cloths"); 19 | System.out.println("Toy"); 20 | } 21 | 22 | } 23 | 24 | 25 | public class RunTimePolymorphism { 26 | public static void main(String[] args) { 27 | orders orderss = new orders(); 28 | orderss.order_info(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Day_06/Practice Questions/Question 1.md: -------------------------------------------------------------------------------- 1 | ## normal billing system 2 | 3 | ```yaml 4 | 5 | -- User input section 6 | Enter Product List Size : 4 7 | Enter Product 1 - 8 | Samosa 9 | Enter Product 2 - 10 | Kachori 11 | Enter Product 3 - 12 | Fafda 13 | Enter Product 4 - 14 | Jalebi 15 | 16 | Enter Samosa Price : 17 | 300/- 18 | Enter Kachori Price : 19 | 100/- 20 | Enter Fafda Price : 21 | 100/- 22 | Enter Jalebi Price : 23 | 200/- 24 | 25 | --- output 26 | 27 | samosa = 300 28 | kachori = 100 29 | fafda = 100 30 | jalebi = 200 31 | 32 | ``` 33 | 34 | ## Billing System (Basic) 35 | 36 | ```yaml 37 | -- User input section 38 | Enter Product List Size : 4 39 | Enter Product 1 - 40 | Samosa 41 | Enter Product 2 - 42 | Kachori 43 | Enter Product 3 - 44 | Fafda 45 | Enter Product 4 - 46 | Jalebi 47 | 48 | Enter Samosa Price : 49 | 300/- 50 | Enter Kachori Price : 51 | 100/- 52 | Enter Fafda Price : 53 | 100/- 54 | Enter Jalebi Price : 55 | 200/- 56 | 57 | Do You Want to add GST [Y/N] 58 | [note : if user select `N` Print bill without GST] 59 | [Note User select yes `Y`] 60 | Enter GST % = 18 61 | -------Out put ------- 62 | 63 | 1. Samosa = 300/- 64 | 2. Kachori = 100/- 65 | 3. Fafda = 100/- 66 | 4. Jalebi = 200/- 67 | ------------------- 68 | Total = 700 69 | GST = 18% 70 | ------------------- 71 | Final Total = 826/- 72 | ------------------- 73 | ``` -------------------------------------------------------------------------------- /Day_06/Practice Questions/Question 2.md: -------------------------------------------------------------------------------- 1 | # advance billing system 2 | 3 | ```yaml 4 | 5 | -- User input section 6 | Enter Product 1 - 7 | Samosa 8 | Do you Want to add more [Y/N] 9 | Y 10 | Enter Product 2 - 11 | Kachori 12 | Do you Want to add more [Y/N] 13 | Y 14 | Enter Product 3 - 15 | Fafda 16 | Do you Want to add more [Y/N] 17 | Y 18 | Enter Product 4 - 19 | Jalebi 20 | Do you Want to add more [Y/N] 21 | N 22 | Enter Samosa Price : 23 | 300/- 24 | Enter Kachori Price : 25 | 100/- 26 | Enter Fafda Price : 27 | 100/- 28 | Enter Jalebi Price : 29 | 200/- 30 | 31 | Do You Want to add GST [Y/N] 32 | [note : if user select `N` Print bill without GST] 33 | [Note User select yes `Y`] 34 | Enter GST % = 18 35 | -------Out put ------- 36 | 37 | 1. Samosa = 300/- 38 | 2. Kachori = 100/- 39 | 3. Fafda = 100/- 40 | 4. Jalebi = 200/- 41 | ------------------- 42 | Total = 700 43 | GST = 18% 44 | ------------------- 45 | Final Total = 826/- 46 | ------------------- 47 | 48 | 49 | 50 | ``` -------------------------------------------------------------------------------- /Day_06/Single_Array.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_06/Single_Array.class -------------------------------------------------------------------------------- /Day_06/Single_Array.java: -------------------------------------------------------------------------------- 1 | package Day_06; 2 | 3 | /** 4 | * Single_Array 5 | */ 6 | public class Single_Array { 7 | 8 | public static void main(String[] args) { 9 | 10 | 11 | int[] data = new int[4]; 12 | 13 | data[0] = 90; 14 | data[1] = 20; 15 | data[2] = 30; 16 | data[3] = 40; 17 | 18 | //System.out.println("data from array = "+data[1]); 19 | 20 | for (int i : data) { 21 | System.out.println("data = "+i); 22 | } 23 | 24 | 25 | } 26 | 27 | 28 | } -------------------------------------------------------------------------------- /Day_06/UserInput.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_06/UserInput.class -------------------------------------------------------------------------------- /Day_06/UserInput.java: -------------------------------------------------------------------------------- 1 | package Day_06; 2 | 3 | import java.util.Scanner; 4 | 5 | public class UserInput { 6 | 7 | public static void main(String[] args) { 8 | 9 | Scanner sc = new Scanner(System.in); 10 | 11 | int size; 12 | 13 | System.out.println("\n---------Enter List Size ----------\n"); 14 | 15 | size = sc.nextInt(); 16 | 17 | String[] food = new String[size]; 18 | 19 | for (int i = 0; i < size; i++) { 20 | 21 | System.out.println(" \n enter food name = " + (i+1)); 22 | food[i] = sc.next(); 23 | 24 | } 25 | 26 | System.out.println("---------out put list ---------------\n"); 27 | 28 | for (int i = 0; i < size; i++) { 29 | 30 | System.out.println((i+1)+". = "+food[i]); 31 | 32 | 33 | } 34 | 35 | 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Day_07/ExceptionHandling.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_07/ExceptionHandling.class -------------------------------------------------------------------------------- /Day_07/ExceptionHandling1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_07/ExceptionHandling1.class -------------------------------------------------------------------------------- /Day_07/ExceptionHandling1.java: -------------------------------------------------------------------------------- 1 | package Day_07; 2 | 3 | import java.util.InputMismatchException; 4 | import java.util.Scanner; 5 | import java.lang.ArithmeticException; 6 | 7 | class ExceptionHandling1{ 8 | 9 | public static void main(String[] args) { 10 | try{ 11 | Scanner sc = new Scanner(System.in); 12 | 13 | System.out.println("Enter your Name "); 14 | String name = sc.nextLine(); 15 | 16 | System.out.println("Enter Your age "); 17 | int age = sc.nextInt(); 18 | 19 | System.out.println("Enter your height"); 20 | int height = sc.nextInt(); 21 | 22 | int BMI = age/height; 23 | 24 | System.out.println("Your Name is "+name); 25 | System.out.println("BMI = "+BMI); 26 | }catch(InputMismatchException e){ 27 | System.out.println("Enter Only Number ....."); 28 | }catch(ArithmeticException e){ 29 | System.out.println("do not enter zero value"); 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /Day_08/Bill.java: -------------------------------------------------------------------------------- 1 | package Day_08; 2 | 3 | public class Bill extends Customers{ 4 | void get_price(){ 5 | System.out.println("order price = "+4500); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Day_08/Customers.java: -------------------------------------------------------------------------------- 1 | package Day_08; 2 | 3 | public class Customers extends Orders{ 4 | 5 | void getCustomersList(){ 6 | System.out.println("Joy"); 7 | System.out.println("toy"); 8 | System.out.println("koy"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Day_08/MainClass.java: -------------------------------------------------------------------------------- 1 | package Day_08; 2 | 3 | public class MainClass { 4 | public static void main(String[] args) { 5 | // Customers customers = new Customers(); 6 | // customers.getCustomersList(); 7 | // customers.get_order_list(); 8 | 9 | Bill bill = new Bill(); 10 | bill.getCustomersList(); 11 | bill.get_order_list(); 12 | bill.get_price(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Day_08/Orders.java: -------------------------------------------------------------------------------- 1 | package Day_08; 2 | 3 | public class Orders { 4 | 5 | void get_order_list(){ 6 | System.out.println("Samosa"); 7 | System.out.println("Jalebi"); 8 | System.out.println("Fafda"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Day_09/Employee_p4n.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Day_09/Employee_p4n.class -------------------------------------------------------------------------------- /Day_09/Employee_p4n.java: -------------------------------------------------------------------------------- 1 | package Day_09; 2 | 3 | class Employee_p4n{ 4 | 5 | String name[]; 6 | double salary[]; 7 | String designation[]; 8 | 9 | Employee_p4n(String[] Name, double[] Salary, String[] Designation) { 10 | name = Name; 11 | salary = Salary; 12 | designation = Designation; 13 | } 14 | 15 | void get_all_data(){ 16 | 17 | int size = name.length; 18 | System.out.println("Sn.no. | Name | Salary | Designation"); 19 | for (int i = 0; i < size; i++) { 20 | 21 | 22 | System.out.println(i+1+" | "+name[i]+" | "+salary[i]+" | "+designation[i]); 23 | 24 | } 25 | 26 | } 27 | 28 | 29 | 30 | 31 | 32 | 33 | } -------------------------------------------------------------------------------- /Day_09/Employee_p4nMain.java: -------------------------------------------------------------------------------- 1 | package Day_09; 2 | 3 | public class Employee_p4nMain { 4 | public static void main(String[] args) { 5 | 6 | String name1[] = {"joy","nishant","alok","omji"}; 7 | double salary1[] = {45000,78000,90000,125000}; 8 | String designation1[] = {"ios","HR","Tech","CA"}; 9 | 10 | 11 | Employee_p4n emp1 = new Employee_p4n(name1,salary1,designation1); 12 | emp1.get_all_data(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Day_10/EmployeeMain.java: -------------------------------------------------------------------------------- 1 | package Day_10; 2 | 3 | class EmployeeMain{ 4 | 5 | 6 | public static void main(String[] args) { 7 | 8 | Employees emps = new Employees("Joy",45000.89); 9 | Employees emp1 = new Employees("Nishant",65000.89); 10 | System.out.println(emps.get_name()); 11 | System.out.println(emps.get_salary()); 12 | 13 | System.out.println(emp1.get_name()); 14 | System.out.println(emp1.get_salary()); 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /Day_10/Employees.java: -------------------------------------------------------------------------------- 1 | package Day_10; 2 | 3 | class Employees{ 4 | String emp_name; 5 | double salary; 6 | Employees(String emp_name,double salary){ 7 | this.emp_name = emp_name; 8 | this.salary = salary; 9 | } 10 | String get_name(){ 11 | return emp_name; 12 | } 13 | double get_salary(){ 14 | return salary; 15 | } 16 | void set_name(String emp_name){ 17 | this.emp_name = emp_name; 18 | } 19 | void set_salary(double salary){ 20 | this.salary = salary; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Day_10/Orders.java: -------------------------------------------------------------------------------- 1 | package Day_10; 2 | public class Orders{ 3 | 4 | Orders(){ 5 | System.out.println("Orders class is initialized"); 6 | } 7 | Orders(int id){ 8 | System.out.println("Orders class is initialized "+id); 9 | } 10 | Orders(String name){ 11 | System.out.println("Orders class is initialized "+name); 12 | } 13 | 14 | // methods overloading 15 | 16 | void getinfo(){ 17 | System.out.println("This is a default method"); 18 | } 19 | void getinfo(int id){ 20 | System.out.println("This is a method with id parameter"+id); 21 | } 22 | 23 | void getinfo(int id, String name){ 24 | System.out.println("this is multi perameter name "+name); 25 | System.out.println("this is multi perameter id "+id); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Day_10/Polymorphism.java: -------------------------------------------------------------------------------- 1 | package Day_10; 2 | 3 | /** 4 | * Polymorphism 5 | */ 6 | public class Polymorphism { 7 | 8 | public static void main(String[] args) { 9 | Orders orders = new Orders(); 10 | Orders orders1 = new Orders(101); 11 | Orders orders2 = new Orders("John"); 12 | orders.getinfo(); 13 | orders.getinfo(101); 14 | orders.getinfo(101,"joy"); 15 | } 16 | } -------------------------------------------------------------------------------- /Day_11/Single/BookPrice.java: -------------------------------------------------------------------------------- 1 | package Day_11.Single; 2 | 3 | 4 | 5 | /** 6 | * BookPrice 7 | */ 8 | public class BookPrice extends Books { 9 | 10 | int Book_price; 11 | int Discount; 12 | int Final_price; 13 | 14 | void get_bookPrice(){ 15 | 16 | System.out.println("Book Price is: "+Book_price); 17 | System.out.println("Book Discount is "+Discount); 18 | System.out.println("Final Price is "+Final_price); 19 | 20 | } 21 | 22 | public static void main(String[] args) { 23 | BookPrice bookPrice = new BookPrice(); 24 | bookPrice.Book_price = 100; 25 | bookPrice.Discount = 10; 26 | bookPrice.Final_price = bookPrice.Book_price - bookPrice.Discount; 27 | bookPrice.get_bookPrice(); 28 | bookPrice.title = "java Tutorial"; 29 | bookPrice.author = "Nishant"; 30 | bookPrice.year = 2024; 31 | bookPrice.info(); 32 | 33 | 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /Day_11/Single/Books.java: -------------------------------------------------------------------------------- 1 | package Day_11.Single; 2 | 3 | 4 | class Books{ 5 | 6 | 7 | String title; 8 | String author; 9 | int year; 10 | 11 | void info(){ 12 | System.out.println("Title: "+title); 13 | System.out.println("Author: "+author); 14 | System.out.println("Year: "+year); 15 | } 16 | 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Day_12/FunctionWithArg.java: -------------------------------------------------------------------------------- 1 | package Day_12; 2 | 3 | public class FunctionWithArg { 4 | 5 | 6 | // what is function with argument 7 | // function with argument is a function that takes some input and perform some operation and return some output 8 | // function with argument is also known as function with parameter 9 | 10 | 11 | // create a function with argument 12 | 13 | static void add(int a, int b){ 14 | int sum = a + b; 15 | System.out.println("Sum of a and b is: "+sum); 16 | } 17 | 18 | public static void main(String[] args) { 19 | 20 | // calling function with argument 21 | add(10, 20); 22 | 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Day_12/Function_01.java: -------------------------------------------------------------------------------- 1 | package Day_12; 2 | 3 | public class Function_01 { 4 | 5 | // Function Definition 6 | 7 | // void functionName(){ 8 | // Function Body 9 | // } 10 | 11 | // create a function name of info 12 | 13 | static void info(){ 14 | System.out.println("welcome to codes with pankaj"); 15 | } 16 | 17 | 18 | public static void main(String[] args) { 19 | 20 | 21 | // Function Calling 22 | info(); 23 | } 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | } -------------------------------------------------------------------------------- /Day_12/Function_With_Return_Type.java: -------------------------------------------------------------------------------- 1 | package Day_12; 2 | 3 | public class Function_With_Return_Type { 4 | 5 | // what is function with return type 6 | // function with return type is a function that takes some input and perform some operation and return some output 7 | // function with return type is also known as function with parameter 8 | 9 | // create a function with return type 10 | 11 | static int add(int a, int b){ 12 | int sum = a + b; 13 | return sum; 14 | } 15 | 16 | static int get_number(){ 17 | return 10; 18 | } 19 | 20 | public static void main(String[] args) { 21 | 22 | // calling function with return type 23 | int result = add(10, 20); 24 | System.out.println("Sum of a and b is: "+result); 25 | 26 | int number = get_number(); 27 | System.out.println("Number is: "+number); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Day_13/Employee.java: -------------------------------------------------------------------------------- 1 | package Day_13; 2 | 3 | public class Employee { 4 | 5 | // create a method 6 | 7 | void info(){ 8 | System.out.println("Employee Information"); 9 | System.out.println("Employee Name: Pankaj"); 10 | System.out.println("Employee Age: 25"); 11 | System.out.println("Employee Salary: 50000"); 12 | } 13 | 14 | 15 | public static void main(String[] args) { 16 | 17 | // create object 18 | 19 | // class_name object_name = new class_name(); 20 | 21 | Employee emp = new Employee(); 22 | emp.info(); 23 | 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Day_14/CreditCard.java: -------------------------------------------------------------------------------- 1 | package Day_14; 2 | 3 | public class CreditCard { 4 | 5 | // create a constructor 6 | // what is a constructor? 7 | // a constructor is a special method that is used to initialize an object of a class in java 8 | 9 | // create a constructor 10 | // default constructor 11 | CreditCard() { 12 | System.out.println("Credit Card Constructor"); 13 | } 14 | 15 | // create a parameterized constructor 16 | // parameterized constructor 17 | 18 | CreditCard(String cardNumber, String cardHolderName, String expiryDate, int cvv) { 19 | System.out.println("Credit Card Constructor"); 20 | System.out.println("Card Number: " + cardNumber); 21 | System.out.println("Card Holder Name: " + cardHolderName); 22 | System.out.println("Expiry Date: " + expiryDate); 23 | System.out.println("CVV: " + cvv); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Day_14/CreditCardMain.java: -------------------------------------------------------------------------------- 1 | package Day_14; 2 | 3 | public class CreditCardMain { 4 | 5 | public static void main(String[] args) { 6 | // create an object of CreditCard class 7 | CreditCard creditCard = new CreditCard(); 8 | // output: Credit Card Constructor 9 | 10 | // create an object of CreditCard class 11 | 12 | CreditCard creditCard1 = new CreditCard("1234 5678 9101 1121", "John Doe", "12/2023", 123); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Encapsulation/Employee.java: -------------------------------------------------------------------------------- 1 | package Encapsulation; 2 | 3 | public class Employee{ 4 | 5 | 6 | String name; 7 | int salary; 8 | String department; 9 | 10 | // create a constructor 11 | 12 | Employee(String Name, int Salary, String Department) { 13 | 14 | name = Name; 15 | salary = Salary; 16 | department = Department; 17 | 18 | } 19 | 20 | String get_name(){ 21 | return name; 22 | } 23 | 24 | int get_salary(){ 25 | return salary; 26 | } 27 | 28 | String get_department(){ 29 | return department; 30 | } 31 | 32 | 33 | void set_name(String Name){ 34 | name = Name; 35 | } 36 | 37 | void set_salary(int Salary){ 38 | salary = Salary; 39 | } 40 | 41 | void set_department(String Department){ 42 | department = Department; 43 | } 44 | 45 | 46 | } -------------------------------------------------------------------------------- /Encapsulation/MainEmployee.java: -------------------------------------------------------------------------------- 1 | package Encapsulation; 2 | 3 | public class MainEmployee { 4 | 5 | public static void main(String[] args) { 6 | 7 | // create an object of Employee 8 | 9 | Employee employee = new Employee("John", 50000, "IT"); 10 | 11 | // get the values using get methods 12 | 13 | System.out.println("Name: " + employee.get_name()); 14 | System.out.println("Salary: " + employee.get_salary()); 15 | System.out.println("Department: " + employee.get_department()); 16 | 17 | // update salary 18 | 19 | employee.set_salary(60000); 20 | 21 | // get the updated salary 22 | System.out.println("Updated Salary: " + employee.get_salary()); 23 | 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Encapsulation/StudentMain.java: -------------------------------------------------------------------------------- 1 | package Encapsulation; 2 | 3 | public class StudentMain { 4 | 5 | public static void main(String[] args) { 6 | 7 | // create a student object 8 | Students student = new Students("John", 20); 9 | 10 | // get the student name and age 11 | System.out.println("Student name: " + student.getStudentName()); 12 | System.out.println("Student age: " + student.getStudentAge()); 13 | 14 | // update student name 15 | student.setStudentName("Jane"); 16 | System.out.println("Updated student name: " + student.getStudentName()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Encapsulation/Students.java: -------------------------------------------------------------------------------- 1 | package Encapsulation; 2 | 3 | public class Students { 4 | String Student_name; 5 | int Student_age; 6 | 7 | Students(String name, int age) { 8 | Student_name = name; 9 | Student_age = age; 10 | } 11 | 12 | String getStudentName(){ 13 | return Student_name; 14 | } 15 | 16 | int getStudentAge(){ 17 | return Student_age; 18 | } 19 | 20 | void setStudentName(String name){ 21 | Student_name = name; 22 | } 23 | 24 | void setStudentAge(int age){ 25 | Student_age = age; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /ExceptionHandling/Hospital.java: -------------------------------------------------------------------------------- 1 | package ExceptionHandling; 2 | import java.util.Scanner; 3 | public class Hospital { 4 | 5 | public static void main(String[] args) { 6 | 7 | // create a BMI calculator 8 | try{ 9 | Scanner sc = new Scanner(System.in); 10 | System.out.println("\n Enter your weight in kg: \n"); 11 | int weight = sc.nextInt(); 12 | System.out.println("\n Enter your height in meters: \n"); 13 | int height = sc.nextInt(); 14 | double bmi = weight / (height * height); 15 | 16 | if(bmi < 18.5){ 17 | throw new ArithmeticException("Underweight"); 18 | } else if(bmi >= 18.5 && bmi < 24.9){ 19 | System.out.println("Normal weight"); 20 | } else if(bmi >= 25 && bmi < 29.9){ 21 | System.out.println("Overweight"); 22 | } else { 23 | System.out.println("Obesity"); 24 | } 25 | } catch(ArithmeticException e){ 26 | System.out.println("Do not Enter 0 for height"); 27 | 28 | 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Inheritance/HierarchicalInheritance.java: -------------------------------------------------------------------------------- 1 | package Inheritance; 2 | 3 | 4 | class Customers{ 5 | 6 | void customerinfo(){ 7 | System.out.println("Customer Info"); 8 | System.out.println("Name: John Doe"); 9 | System.out.println("Age: 20"); 10 | } 11 | 12 | } 13 | class CreditCard extends Customers{ 14 | 15 | void creditcardinfo(){ 16 | System.out.println("Credit Card Info"); 17 | System.out.println("Card Type: Visa"); 18 | System.out.println("Card Number: 1234 5678 9101 1121"); 19 | } 20 | 21 | } 22 | class loan extends Customers{ 23 | 24 | void loaninfo(){ 25 | System.out.println("Loan Info"); 26 | System.out.println("Loan Amount: $1000"); 27 | System.out.println("Loan Type: Personal Loan"); 28 | } 29 | 30 | } 31 | 32 | 33 | 34 | 35 | public class HierarchicalInheritance { 36 | 37 | public static void main(String[] args) { 38 | CreditCard c = new CreditCard(); 39 | loan l = new loan(); 40 | c.customerinfo(); 41 | c.creditcardinfo(); 42 | l.customerinfo(); 43 | l.loaninfo(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Inheritance/Multilevelinheritance.java: -------------------------------------------------------------------------------- 1 | package Inheritance; 2 | 3 | 4 | class Student{ 5 | 6 | void info(){ 7 | System.out.println("Student Info"); 8 | System.out.println("Name: John Doe"); 9 | System.out.println("Age: 20"); 10 | } 11 | 12 | } 13 | class course extends Student{ 14 | 15 | void courseinfo(){ 16 | System.out.println("Course Info"); 17 | System.out.println("Course: Computer Science"); 18 | System.out.println("Year: 2020"); 19 | } 20 | 21 | } 22 | 23 | class result extends course{ 24 | 25 | void resultinfo(){ 26 | System.out.println("Result Info"); 27 | System.out.println("Marks: 90%"); 28 | System.out.println("Grade: A"); 29 | } 30 | 31 | } 32 | 33 | 34 | 35 | 36 | public class Multilevelinheritance { 37 | 38 | public static void main(String[] args) { 39 | result r = new result(); 40 | r.info(); 41 | r.courseinfo(); 42 | r.resultinfo(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Inheritance/MultipleInheritance.java: -------------------------------------------------------------------------------- 1 | package Inheritance; 2 | 3 | 4 | interface gst{ 5 | 6 | void gstinfo(); 7 | 8 | } 9 | 10 | 11 | class Product{ 12 | 13 | void productinfo(){ 14 | System.out.println("Product Info"); 15 | System.out.println("Product Name: Laptop"); 16 | System.out.println("Product Price: $1000"); 17 | } 18 | 19 | } 20 | 21 | class shop extends Product implements gst{ 22 | 23 | public void gstinfo(){ 24 | System.out.println("GST Info"); 25 | System.out.println("GST Amount: $100"); 26 | System.out.println("GST Type: Sales Tax"); 27 | } 28 | 29 | } 30 | 31 | 32 | public class MultipleInheritance { 33 | 34 | public static void main(String[] args) { 35 | shop s = new shop(); 36 | s.productinfo(); 37 | s.gstinfo(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Inheritance/OtherExample/Child.java: -------------------------------------------------------------------------------- 1 | package Inheritance.OtherExample; 2 | 3 | public class Child extends Parent { 4 | 5 | public void child_display() { 6 | System.out.println("Child class display method"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Inheritance/OtherExample/MainClass.java: -------------------------------------------------------------------------------- 1 | package Inheritance.OtherExample; 2 | 3 | public class MainClass { 4 | 5 | public static void main(String[] args) { 6 | Child child = new Child(); 7 | child.display(); 8 | child.child_display(); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Inheritance/OtherExample/Parent.java: -------------------------------------------------------------------------------- 1 | package Inheritance.OtherExample; 2 | 3 | public class Parent { 4 | 5 | public void display() { 6 | System.out.println("Parent class display method"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Inheritance/Singleinheritance.java: -------------------------------------------------------------------------------- 1 | package Inheritance; 2 | 3 | 4 | 5 | class Animal { 6 | 7 | void eat(){ 8 | System.out.println("Eating"); 9 | } 10 | 11 | } 12 | 13 | class Dog extends Animal{ 14 | 15 | void bark(){ 16 | System.out.println("Barking"); 17 | } 18 | 19 | } 20 | 21 | public class Singleinheritance { 22 | 23 | public static void main(String[] args) { 24 | 25 | Dog d = new Dog(); 26 | d.eat(); 27 | d.bark(); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /InterFace/client.java: -------------------------------------------------------------------------------- 1 | package InterFace; 2 | 3 | interface Tax{ 4 | void taxinfo(); 5 | } 6 | 7 | 8 | public class client implements Tax{ 9 | 10 | 11 | public void taxinfo(){ 12 | System.out.println("Tax Info"); 13 | System.out.println("Tax Amount: $100"); 14 | System.out.println("Tax Type: Sales Tax"); 15 | } 16 | 17 | public static void main(String[] args) { 18 | client c = new client(); 19 | c.taxinfo(); 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /Java_String/Advance_Example.java: -------------------------------------------------------------------------------- 1 | package Java_String; 2 | 3 | public class Advance_Example { 4 | 5 | public static void main(String[] args) { 6 | 7 | String str = "Hello, World!"; 8 | 9 | StringBuilder obj = new StringBuilder(str); 10 | System.out.println(obj); 11 | 12 | StringBuffer data1 = new StringBuffer("welcome"); 13 | System.out.println(data1); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Java_String/Basic_Example.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Java_String/Basic_Example.class -------------------------------------------------------------------------------- /Java_String/Basic_Example.java: -------------------------------------------------------------------------------- 1 | package Java_String; 2 | 3 | public class Basic_Example { 4 | 5 | 6 | public static void main(String[] args) { 7 | 8 | String data = "welcome to codes with pankaj"; 9 | System.err.println(data); 10 | 11 | String First_Name = "Joy"; 12 | String Last_Name = "Jain"; 13 | String Full_Name = First_Name + " " + Last_Name; 14 | 15 | System.err.println("Full Name is "+Full_Name); 16 | 17 | // upper() 18 | 19 | System.out.println(Full_Name.toUpperCase()); 20 | System.out.println(Full_Name.toLowerCase()); 21 | 22 | // len 23 | 24 | System.out.println(Full_Name.length()); 25 | 26 | // substring(int beginIndex): 27 | 28 | 29 | System.out.println(data.substring(10)); 30 | 31 | // substring(int beginIndex, int endIndex) 32 | 33 | System.out.println(data.substring(10,20)); 34 | 35 | String str1 = "p4n"; 36 | String str2 = "P4n"; 37 | 38 | // equals(String anotherString) 39 | 40 | System.err.println(str1.equals(str2)); 41 | 42 | // equalsIgnoreCase(String anotherString): 43 | 44 | System.out.println(str1.equalsIgnoreCase(str2)); 45 | 46 | // startsWith(String prefix) 47 | 48 | System.out.println(data.startsWith("codes")); 49 | 50 | // endsWith(String suffix) 51 | System.err.println(data.endsWith("pankaj")); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Pankaj Chouhan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Map/Mapexample.java: -------------------------------------------------------------------------------- 1 | package Map; 2 | 3 | import java.util.HashMap; 4 | 5 | public class Mapexample { 6 | 7 | public static void main(String[] args) { 8 | 9 | 10 | HashMap data = new HashMap(); 11 | 12 | data.put(101, "cloth"); 13 | data.put(102, "shoes"); 14 | data.put(103, "book"); 15 | data.put(104, "pencil"); 16 | data.put(105, "bag"); 17 | data.put(106, "watch"); 18 | 19 | 20 | // print data 21 | System.out.println("Data: " + data); 22 | 23 | // remove data 24 | data.remove(102); 25 | 26 | System.out.println("Data "+data); 27 | 28 | // get all keys 29 | 30 | System.out.println(data.get(101)); 31 | 32 | 33 | // interating (fatch data using loop) 34 | 35 | for(HashMap.Entry u_data : data.entrySet()){ 36 | System.out.println(u_data.getKey() + " " + u_data.getValue()); 37 | } 38 | 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JAVA-Topic-Example 2 | Java Advanced Topics and Techniques (Java Interview Questions for Freshers) 3 | 4 | Learn more Java Tutorial 5 | ### https://github.com/Pankaj-Str/JAVA-SE-Tutorial-codeswithpankaj 6 | -------------------------------------------------------------------------------- /Set/Set_Example01.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Set/Set_Example01.class -------------------------------------------------------------------------------- /Set/Set_Example01.java: -------------------------------------------------------------------------------- 1 | package Set; 2 | 3 | import java.util.*; 4 | 5 | public class Set_Example01 { 6 | 7 | public static void main(String[] args) { 8 | 9 | // set in python 10 | 11 | Set data = new HashSet<>(); 12 | 13 | data.add(100); 14 | data.add(200); 15 | data.add(300); 16 | data.add(100); 17 | data.add(400); 18 | 19 | 20 | System.err.println("data : "+data); 21 | 22 | // Check if an element is in the set 23 | boolean containsdata = data.contains(100); // true 24 | System.err.println(containsdata); 25 | 26 | // remove data 27 | 28 | data.remove(200); 29 | System.err.println(data); 30 | 31 | 32 | for (Integer integer : data) { 33 | System.err.println(integer); 34 | } 35 | 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Strings/StringBuilder1.java: -------------------------------------------------------------------------------- 1 | package Strings; 2 | 3 | public class StringBuilder1 { 4 | 5 | public static void main(String[] args) { 6 | 7 | // string builder 8 | 9 | StringBuilder str = new StringBuilder("Hello World"); 10 | 11 | System.out.println(str); 12 | 13 | // String Concatenation 14 | 15 | str.append(" Java"); 16 | 17 | System.out.println(str); 18 | 19 | 20 | // String Length 21 | System.out.println(str.length()); 22 | 23 | 24 | // String Comparison 25 | System.out.println(str.equals("Hello World Java")); 26 | 27 | 28 | // upper case and lower case 29 | System.out.println(str.toString().toUpperCase()); 30 | System.out.println(str.toString().toLowerCase()); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Strings/String_Example01.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Pankaj-Str/JAVA-Topic-Example/c87afed146845a00c936cfa85e9d0451fbc25905/Strings/String_Example01.class -------------------------------------------------------------------------------- /Strings/String_Example01.java: -------------------------------------------------------------------------------- 1 | package Strings; 2 | 3 | public class String_Example01 { 4 | 5 | 6 | public static void main(String[] args) { 7 | 8 | String str = "Hello World"; 9 | System.out.println(str); 10 | 11 | 12 | // String Concatenation 13 | 14 | String str1 = "codes with"; 15 | String str2 = "Pankaj"; 16 | 17 | String str3 = str1 + " " + str2; 18 | 19 | System.out.println(str3); 20 | 21 | 22 | // String Length 23 | 24 | String data = "codes with Pankaj"; 25 | 26 | int length = data.length(); 27 | System.out.println("Length of the string is: " + length); 28 | 29 | 30 | // String Comparison 31 | 32 | String str4 = "Hello"; 33 | String str5 = "Hellow"; 34 | 35 | if(str4.equals(str5)){ 36 | System.out.println("Strings are equal"); 37 | }else{ 38 | System.out.println("Strings are not equal"); 39 | } 40 | 41 | // upper case and lower case 42 | 43 | System.out.println(data.toUpperCase()); 44 | System.out.println(data.toLowerCase()); 45 | 46 | // String Substring 47 | 48 | String data1 = "codes with Pankaj"; 49 | System.out.println(data1.substring(0, 10)); 50 | 51 | 52 | // String Replace 53 | 54 | System.out.println(data1.replace("Pankaj", "Nishant")); 55 | 56 | 57 | // String Split 58 | 59 | 60 | String[] words = data.split(" "); 61 | for(String word: words){ 62 | System.out.println(word); 63 | } 64 | 65 | 66 | 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /Strings/Stringbuffer_example.java: -------------------------------------------------------------------------------- 1 | package Strings; 2 | 3 | public class Stringbuffer_example { 4 | 5 | public static void main(String[] args) { 6 | 7 | StringBuffer str = new StringBuffer("Hello World"); 8 | System.out.println(str); 9 | 10 | // String Concatenation 11 | str.append(" Java"); 12 | 13 | System.out.println(str); 14 | 15 | // String Length 16 | System.out.println("Length of the string is: " + str.length()); 17 | 18 | // String Comparison 19 | 20 | StringBuffer str1 = new StringBuffer("Hello"); 21 | StringBuffer str2 = new StringBuffer("Hello"); 22 | System.out.println(str1.equals(str2)); // true 23 | System.out.println(str1.equals(str)); // false 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SuperKeyword/customer.java: -------------------------------------------------------------------------------- 1 | package SuperKeyword; 2 | 3 | 4 | class Card { 5 | 6 | void info(){ 7 | System.out.println("Card name - ICICI bank"); 8 | System.out.println("Card type - Debit card"); 9 | System.out.println("Card number - 1234 5678 9012 3456"); 10 | System.out.println("Card holder name - John Doe"); 11 | } 12 | 13 | } 14 | 15 | class Bank extends Card { 16 | 17 | void info(){ 18 | super.info(); 19 | System.out.println("Bank name - ICICI bank"); 20 | System.out.println("Bank branch - Bangalore"); 21 | System.out.println("Bank IFSC code - ICIC0001234"); 22 | } 23 | 24 | } 25 | 26 | public class customer{ 27 | 28 | public static void main(String[] args) { 29 | Bank b = new Bank(); 30 | b.info(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Threading/SingleThread.java: -------------------------------------------------------------------------------- 1 | package Threading; 2 | 3 | public class SingleThread implements Runnable { 4 | 5 | 6 | @Override 7 | public void run() { 8 | 9 | try{ 10 | for(int i = 0; i < 10; i++) { 11 | System.out.println("Thread: " + i); 12 | Thread.sleep(1000); 13 | } 14 | } catch (InterruptedException e) { 15 | e.printStackTrace(); 16 | } 17 | 18 | } 19 | 20 | 21 | public static void main(String[] args) { 22 | 23 | // Create a new thread 24 | 25 | Thread thread = new Thread(new SingleThread()); 26 | thread.start(); 27 | 28 | 29 | 30 | } 31 | 32 | } 33 | --------------------------------------------------------------------------------