├── README.md ├── basics ├── Arithmetic.java ├── Exception.java ├── TryBlock.java ├── stringHandling.java └── student.java ├── generics ├── GenericMethod.java ├── GenericTest.java └── Pair.java ├── homework.md ├── java-class ├── ArrayHW.java ├── StudentMark.java ├── array_avg.java ├── bike.class ├── bike.java ├── bikeMain.java ├── clg_management │ ├── Main.java │ └── inherit │ │ ├── Math.java │ │ ├── Person.java │ │ ├── Science.java │ │ ├── Staff.java │ │ └── Student.java ├── hello.class ├── hello.java ├── loop.class ├── loop.java ├── myArray.java └── operators.java └── oops ├── Car.java ├── Vehicle.java └── myVehicle.java /README.md: -------------------------------------------------------------------------------- 1 | # Java Workshop programs and Homework 2 | 3 | This is for the co-students joined in the workshop 4 | -------------------------------------------------------------------------------- /basics/Arithmetic.java: -------------------------------------------------------------------------------- 1 | public class Arithmetic { 2 | public static int add(int a, int b) { //create a method named add with argument a and b 3 | return a + b; // return the value of a + b 4 | } 5 | public static int findSum(int n) { 6 | return n*(n+1)/2; // sum of the first n formula 7 | } 8 | public static int getSum(int n) { 9 | int sum = 0; 10 | for(int i=1;i<=n;i++) { 11 | sum += i; 12 | } 13 | return sum; 14 | } 15 | public static boolean isEven(int n) { 16 | return n%2==0; 17 | } 18 | public static void main(String[] args) { 19 | 20 | // System.out.println(findSum(5)); 21 | int sum = add(2,4); // call the method and store that return value in sum variable 22 | System.out.println(sum); // call the sum variable 23 | System.out.println(isEven(6)); // directly call the method in print statement 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /basics/Exception.java: -------------------------------------------------------------------------------- 1 | import java.util.List; 2 | 3 | public class Exception { 4 | public static void main(String[] args) { 5 | myMethod(); 6 | 7 | } 8 | 9 | private static void myMethod() { 10 | try { 11 | List list = (List) Class.forName("com.techatpark.practices.oops.HelloClass").newInstance(); 12 | list.add("VJ"); 13 | System.out.println(list); 14 | } 15 | catch(ClassNotFoundException cnf){ 16 | System.out.println("Class ah kanam..."); 17 | } catch (InstantiationException e) { 18 | System.out.println("Instance create panna mutiyalaa..."); 19 | } catch (IllegalAccessException e) { 20 | System.out.println("You are under arrest!"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /basics/TryBlock.java: -------------------------------------------------------------------------------- 1 | public class TryBlock { 2 | public static int divite(int i ,int j){ 3 | 4 | int ans=0; 5 | try{ 6 | ans=i/j; 7 | } 8 | catch(ArithmeticException a){ 9 | System.out.println("0 can't devide by any number..."); 10 | } 11 | return ans; 12 | } 13 | public static void main(String[] args) { 14 | int Result = divite(15, 2); 15 | System.out.println(Result); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /basics/stringHandling.java: -------------------------------------------------------------------------------- 1 | public class stringHandling { 2 | private static String getString() { 3 | String string = "This is my first string program,I don't want to mess up with this"; 4 | return string; 5 | } 6 | 7 | public static void main(String[] args) { 8 | 9 | String string = getString(); 10 | String[] splitsent = string.split("\\,"); 11 | for (String sentence : splitsent) { 12 | System.out.println("Divideing Two Sentence"); 13 | System.out.println(sentence); 14 | } 15 | 16 | int count = 0; 17 | int countSpaces = 0; 18 | 19 | 20 | for (int i = 0; i < string.length(); i++) { 21 | if (string.charAt(i) == 'i') { 22 | count++; 23 | } 24 | if (string.charAt(i) == ' ') { 25 | countSpaces++; 26 | } 27 | 28 | } 29 | System.out.println("Counting i"); 30 | System.out.println("The letter 'i' appears " + count + " times in the sentence."); 31 | 32 | System.out.println("Counting spaces"); 33 | System.out.println("The spaces appears " + countSpaces + " time in the sentence"); 34 | 35 | String[] words = string.split(" "); 36 | for (String word : words) { 37 | System.out.println(word); 38 | } 39 | 40 | StringBuilder CamelCase = new StringBuilder(); 41 | boolean nextUpperCase = false; 42 | for (char c : string.toCharArray()) { 43 | if (c == ' ' || c == ',') { 44 | nextUpperCase = true; 45 | } else { 46 | if (nextUpperCase) { 47 | CamelCase.append(" ") 48 | .append(Character.toUpperCase(c)); 49 | nextUpperCase = false; 50 | } else { 51 | CamelCase.append(Character.toLowerCase(c)); 52 | } 53 | } 54 | } 55 | 56 | System.out.println("CamelCase words: " + CamelCase); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /basics/student.java: -------------------------------------------------------------------------------- 1 | public class student { 2 | private int id; 3 | private String name; 4 | public void setId(int aId) { 5 | id = aId; 6 | } 7 | public int getId() { 8 | return id; 9 | } 10 | 11 | public void setName(String aName) { 12 | name = aName; 13 | } 14 | public String getName() { 15 | return name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /generics/GenericMethod.java: -------------------------------------------------------------------------------- 1 | package generics; 2 | 3 | public class GenericMethod { 4 | 5 | public static void print(T elements) { 6 | System.out.println(elements + " is " + elements.getClass().getName()); 7 | 8 | } 9 | 10 | public static void main(String[] args) { 11 | print(1); 12 | print("Hello world"); 13 | print(10.5); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /generics/GenericTest.java: -------------------------------------------------------------------------------- 1 | package generics; 2 | 3 | public class GenericTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | Pair genericStudent = new Pair<>(); 8 | genericStudent.setKey("Abhishek"); 9 | genericStudent.setValue(34234); 10 | System.out.println("Name :" + genericStudent.getKey() + " Id :" + genericStudent.getValue()); 11 | 12 | Pair rmkStudent = new Pair<>(); 13 | rmkStudent.setKey("Raja"); 14 | rmkStudent.setValue("23USC013"); 15 | 16 | System.out.println("Name :" + rmkStudent.getKey() + " Id :" + rmkStudent.getValue()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /generics/Pair.java: -------------------------------------------------------------------------------- 1 | package generics; 2 | 3 | public class Pair { 4 | K key; 5 | V value; 6 | 7 | public K getKey() { 8 | return key; 9 | } 10 | 11 | public void setKey(K key) { 12 | this.key = key; 13 | } 14 | 15 | public V getValue() { 16 | return value; 17 | } 18 | 19 | public void setValue(V value) { 20 | this.value = value; 21 | } 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /homework.md: -------------------------------------------------------------------------------- 1 | ## Day - 2 (19Sep) 2 | - Type of datatypes 3 | - Range for datatype 4 | - Bytes for datatypes 5 | - Java operators 6 | - Create Car class and create methods for that behaviors 7 | 8 | ## Day - 3 (20Sep) 9 | - Typesafety in generics 10 | - collections framework 11 | - list 12 | - exception handling 13 | - compile time exception 14 | - file handling 15 | -------------------------------------------------------------------------------- /java-class/ArrayHW.java: -------------------------------------------------------------------------------- 1 | public class ArrayHW { 2 | 3 | public static void main(String[] arg) { 4 | ArrayHW arrayHW = new ArrayHW(); 5 | arrayHW.reverseArray2(); 6 | 7 | } 8 | 9 | private void arraySum(){ 10 | int[] arr = {1, 2, 3, 4, 5}; 11 | int sum = 0; 12 | 13 | for(int a : arr){ 14 | sum += a; 15 | } 16 | System.out.println("Sum of the array is : " + sum); 17 | } 18 | 19 | private void maxValue() { 20 | int[] arr = {1, 2, 7, 4, 5}; 21 | int max = arr[0]; 22 | for (int i = 1; i < arr.length; i++) { 23 | if (arr[i] > max) { 24 | max = arr[i]; 25 | } 26 | } 27 | System.out.println("Maximum value in the array is : " + max); 28 | } 29 | 30 | private void reverseArray() { 31 | int[] array = {1, 2, 3, 4, 5}; 32 | int[] array2 = new int[array.length]; 33 | 34 | System.out.print("Original array: "); 35 | for (int num : array) { 36 | System.out.print(num + " "); 37 | } 38 | for (int i = 0; i < array.length; i++) { 39 | array2[i] = array[array.length - 1 - i]; 40 | } 41 | 42 | System.out.print("\nReversed array: "); 43 | for (int num : array2) { 44 | System.out.print(num + " "); 45 | } 46 | } 47 | 48 | private void reverseArray2() { 49 | int[] array = {1, 2, 3, 4, 5}; 50 | int start = 0; 51 | int end = array.length - 1; 52 | System.out.print("Original array: "); 53 | for (int num : array) { 54 | System.out.print(num + " "); 55 | } 56 | while (start < end) { 57 | int temp = array[start]; 58 | array[start] = array[end]; 59 | array[end] = temp; 60 | start++; 61 | end--; 62 | } 63 | System.out.print("\nReversed array: "); 64 | for (int i : array) { 65 | System.out.print(i + " "); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /java-class/StudentMark.java: -------------------------------------------------------------------------------- 1 | public class StudentMark { 2 | public static void main(String[] args) { 3 | int[] marks = { 50, 60, 70, 80, 90 }; 4 | 5 | // Length of the array 6 | System.out.println("My Array length is : " + marks.length); 7 | 8 | // Accessing an array element 9 | System.out.println("My science mark: " + marks[3]); 10 | 11 | // Iterating over an array 12 | int total = 0; 13 | for (int i = 0; i < marks.length; i++) { 14 | System.out.println("Mark in subject " + (i + 1) + ": " + marks[i]); 15 | total += marks[i]; 16 | } 17 | 18 | System.out.println("Total marks: " + total); 19 | System.out.println("Average marks: " + total / marks.length); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /java-class/array_avg.java: -------------------------------------------------------------------------------- 1 | import java.util.stream.IntStream; 2 | 3 | public class array_avg { 4 | 5 | public static void main(String[] args) { 6 | int[] arr1 = {10, 20, 30, 40, 50}; 7 | int[] arr2 = {5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105}; 8 | 9 | int[] mergedArray = IntStream.concat(IntStream.of(arr1), IntStream.of(arr2)).toArray(); 10 | 11 | int arr3 = mergedArray[mergedArray. length / 2]; 12 | 13 | System.out.println("Middle element of merged array: " + arr3); 14 | } 15 | } -------------------------------------------------------------------------------- /java-class/bike.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIJAYWHAT/java-workshop/c457a2bbac83c1ec4a32869d0480ced5c990027b/java-class/bike.class -------------------------------------------------------------------------------- /java-class/bike.java: -------------------------------------------------------------------------------- 1 | public class bike { 2 | private String brand; 3 | private String model; 4 | private String color; 5 | 6 | public bike(String brand, String model, String color) { 7 | this.brand = brand; 8 | this.model = model; 9 | this.color = color; 10 | } 11 | 12 | public String getBrand() { 13 | return this.brand; 14 | } 15 | 16 | public String getModel() { 17 | return this.model; 18 | } 19 | 20 | public String getColor() { 21 | return this.color; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /java-class/bikeMain.java: -------------------------------------------------------------------------------- 1 | public class bikeMain { 2 | 3 | public static void main(String[] args) { 4 | bike myBike = new bike("Bajaj", "Pulsar", "black"); 5 | 6 | System.out.println("Brand: " + myBike.getBrand()); 7 | System.out.println("Model: " + myBike.getModel()); 8 | System.out.println("Color: " + myBike.getColor()); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /java-class/clg_management/Main.java: -------------------------------------------------------------------------------- 1 | package clg_management; 2 | import clg_management.inherit.Staff; 3 | import clg_management.inherit.Student; 4 | import clg_management.inherit.Math; 5 | import clg_management.inherit.Science; 6 | 7 | public class Main { 8 | public static void main(String[] args) { 9 | Staff staff = new Staff(); 10 | staff.setName("Vijay"); 11 | staff.setAge(30); 12 | staff.setSalary(50000); 13 | 14 | // staff.introduce(); 15 | // staff.doPerReview(); 16 | 17 | Student student = new Student(); 18 | 19 | student.doActivity(); 20 | staff.doActivity(); 21 | 22 | Math math = new Math(); 23 | Science science = new Science(); 24 | 25 | math.takeEvaluation(); 26 | science.takeEvaluation(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /java-class/clg_management/inherit/Math.java: -------------------------------------------------------------------------------- 1 | package clg_management.inherit; 2 | 3 | public class Math extends Student { 4 | 5 | String subject; 6 | 7 | public void setSubject(String subject) { 8 | this.subject = subject; 9 | } 10 | 11 | public String getSubject() { 12 | return subject; 13 | } 14 | 15 | public void takeEvaluation() { 16 | System.out.println("Maths Student Take an evaluation"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /java-class/clg_management/inherit/Person.java: -------------------------------------------------------------------------------- 1 | package clg_management.inherit; 2 | 3 | public abstract class Person { 4 | 5 | // Comon attributes 6 | String collegeName; 7 | String name; 8 | int age; 9 | 10 | Person(){ 11 | collegeName = "ABC College"; 12 | } 13 | 14 | public void introduce() { 15 | System.out.println("Hello, I am " + name + " from " + collegeName + " and I am " + age + " years old."); 16 | } 17 | 18 | abstract void doActivity(); 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public void setAge(int age) { 25 | this.age = age; 26 | } 27 | 28 | public void setCollegeName(String collegeName) { 29 | this.collegeName = collegeName; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public int getAge() { 37 | return age; 38 | } 39 | 40 | public String getCollegeName() { 41 | return collegeName; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /java-class/clg_management/inherit/Science.java: -------------------------------------------------------------------------------- 1 | package clg_management.inherit; 2 | 3 | public class Science extends Student { 4 | 5 | String subject; 6 | 7 | public void setSubject(String subject) { 8 | this.subject = subject; 9 | } 10 | 11 | public String getSubject() { 12 | return subject; 13 | } 14 | 15 | public void takeEvaluation() { 16 | System.out.println("Science Student Take an evaluation"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /java-class/clg_management/inherit/Staff.java: -------------------------------------------------------------------------------- 1 | package clg_management.inherit; 2 | 3 | public class Staff extends Person { 4 | 5 | int salary; 6 | 7 | public void setSalary(int salary) { 8 | this.salary = salary; 9 | } 10 | 11 | public int getSalary() { 12 | return salary; 13 | } 14 | 15 | public void doActivity() { 16 | System.out.println("Staff will be conducting the exams."); 17 | } 18 | 19 | public void doPerReview() { 20 | System.out.println("Performing review of staff."); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /java-class/clg_management/inherit/Student.java: -------------------------------------------------------------------------------- 1 | package clg_management.inherit; 2 | 3 | public class Student extends Person { 4 | 5 | String dept; 6 | int rollNo; 7 | 8 | public void setDept(String dept) { 9 | this.dept = dept; 10 | } 11 | 12 | public void setRollNo(int rollNo) { 13 | this.rollNo = rollNo; 14 | } 15 | 16 | public String getDept() { 17 | return dept; 18 | } 19 | 20 | public void doActivity() { 21 | System.out.println("Student will be attending the exams."); 22 | } 23 | 24 | void takeEvaluation() { 25 | System.out.println("Student Take an evaluation"); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /java-class/hello.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIJAYWHAT/java-workshop/c457a2bbac83c1ec4a32869d0480ced5c990027b/java-class/hello.class -------------------------------------------------------------------------------- /java-class/hello.java: -------------------------------------------------------------------------------- 1 | public class hello { 2 | public static void main(String[] args) { 3 | System.out.println("Hello, World!"); 4 | } 5 | } -------------------------------------------------------------------------------- /java-class/loop.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VIJAYWHAT/java-workshop/c457a2bbac83c1ec4a32869d0480ced5c990027b/java-class/loop.class -------------------------------------------------------------------------------- /java-class/loop.java: -------------------------------------------------------------------------------- 1 | public class loop { 2 | 3 | public static void main(String[] args) { 4 | int[] numbers = {1, 2, 3, 4}; 5 | int searchkey = 10; 6 | boolean result = false; 7 | 8 | for(int n : numbers) { 9 | if(n == searchkey) { 10 | result = true; 11 | break; 12 | } 13 | else { 14 | result = false; 15 | } 16 | 17 | } 18 | if (result == true) { 19 | System.out.println("Number found"); 20 | 21 | } 22 | else{ 23 | System.out.println("Number not found"); 24 | 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /java-class/myArray.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | public class myArray { 4 | public static void main(String[] args) { 5 | 6 | myArray obj = new myArray(); 7 | obj.twoDArray(); 8 | 9 | } 10 | 11 | private void basicArray(){ 12 | int[] array = new int[5]; 13 | array[0] = 10; 14 | array[1] = 20; 15 | array[2] = 30; 16 | array[3] = 40; 17 | array[4] = 50; 18 | System.out.println("Basic Array"); 19 | 20 | System.out.println("First element of array: " + array[0]); // Prints the first element of the array 21 | System.out.println("Last element of array: " + array[array.length - 1]); // Prints the last element of the array 22 | 23 | System.out.println("Array length is : " + array.length); 24 | 25 | for (int i = 0; i < array.length; i++) { 26 | System.out.println(array[i]); 27 | } 28 | } 29 | 30 | 31 | private void twoDArray() { 32 | int[][] twoDArray = new int[3][3]; 33 | twoDArray[0][0] = 1; 34 | twoDArray[0][1] = 2; 35 | twoDArray[0][2] = 3; 36 | twoDArray[1][0] = 4; 37 | twoDArray[1][1] = 5; 38 | twoDArray[1][2] = 6; 39 | twoDArray[2][0] = 7; 40 | twoDArray[2][1] = 8; 41 | twoDArray[2][2] = 9; 42 | // int[][] twoDArray = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; // Another way to declare a 2D array 43 | 44 | System.out.println("Two Dimensional Array"); 45 | // Nested loops to iterate over the 2D array 46 | for (int i = 0; i < twoDArray.length; i++) { 47 | for (int j = 0; j < twoDArray[i].length; j++) { 48 | System.out.print(twoDArray[i][j] + " "); 49 | } 50 | System.out.println(); 51 | } 52 | 53 | String[][] student = { 54 | {"Alice", "A"}, 55 | {"Bob", "B"}, 56 | {"Charlie", "C"} 57 | }; 58 | 59 | for (int i = 0; i < student.length; i++) { 60 | for (int j = 0; j < student[i].length; j++) { 61 | System.out.println("Student " + (i+1) + " : " + student[i][j]); 62 | } 63 | } 64 | } 65 | private void ArrayFunc() { 66 | String[] classList = {"A", "B", "C", "D", "E"}; 67 | 68 | System.out.println(Arrays.toString(classList)); // Prints the array as a string 69 | 70 | int index = Arrays.binarySearch(classList, "D"); 71 | System.out.println("Index of D is : " + index); 72 | 73 | int[] numbers = new int[5]; // Declares an empty array of integers 74 | Arrays.fill(numbers, 4); // Fills the array with the specified value 75 | System.out.println(Arrays.toString(numbers)); 76 | } 77 | 78 | private void CopyArray() { 79 | String[] classList = {"A", "B", "C", "D", "E"}; 80 | 81 | String[] copyList = new String[classList.length]; 82 | for (int i = 0; i < classList.length; i++) { 83 | copyList[i] = classList[i]; 84 | } 85 | System.out.print("Original Array : "); 86 | for (int i = 0; i < classList.length; i++) { 87 | System.out.print(classList[i] + ", "); 88 | } 89 | System.out.print("\nCopied Array : "); 90 | for (int i = 0; i < copyList.length; i++) { 91 | System.out.print(copyList[i] + ", "); 92 | } 93 | } 94 | 95 | private void nameSearch() { 96 | String [] names = {"Abi", "Dinesh", "Udhaya", "VJ"}; 97 | String searchName = "VJ "; 98 | boolean result = false; 99 | for (int i = 0; i < names.length; i++) { 100 | if (names[i].equals(searchName)) { 101 | result = true; 102 | break; 103 | } 104 | else { 105 | result = false; 106 | } 107 | } 108 | if (result == true) { 109 | System.out.println("Name found"); 110 | } 111 | else { 112 | System.out.println("Name not found"); 113 | } 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /java-class/operators.java: -------------------------------------------------------------------------------- 1 | public class operators { 2 | 3 | int a; 4 | int b; 5 | int result; 6 | 7 | public operators() { 8 | a = 10; 9 | b = 3; 10 | } 11 | 12 | public void arithmetic() { 13 | result = a + b; 14 | System.out.println("Sum of the two number is : " + result); 15 | 16 | result = a - b; 17 | System.out.println("Substraction of the two number is : " + result); 18 | 19 | result = a * b; 20 | System.out.println("Multiplication of the two number is : " + result); 21 | 22 | result = a / b; 23 | System.out.println("Divition of the two number is : " + result); 24 | 25 | } 26 | 27 | public void comparison() { 28 | if (a > b) { 29 | System.out.println("a is greater than b"); 30 | } 31 | 32 | if (a < b) { 33 | System.out.println("a is less than b"); 34 | } 35 | 36 | if (a == b) { 37 | System.out.println("They are both equal"); 38 | } 39 | 40 | // > greater than 41 | // < less than 42 | // == equal condition 43 | // > == greater than or equal to 44 | // <== less than or equal to 45 | 46 | } 47 | 48 | public static void main(String[] args) { 49 | operators obj = new operators(); 50 | obj.arithmetic(); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /oops/Car.java: -------------------------------------------------------------------------------- 1 | package oops; 2 | 3 | public class Car extends Vehicle { // created Car class 4 | 5 | String brand; 6 | 7 | public Car(String aColor, String aBrand) { // create constructor for Car 8 | super(aColor); // give the value to parent class constructor 9 | this.brand = aBrand; // set the brand (this - reference variable that refers to the current object) 10 | this.speed = 0; // set the initial speed as 0 11 | } 12 | 13 | public void applyAcc(int speed) { 14 | this.speed += speed; // increase the value for speed 15 | System.out.println("Speed: " + this.speed); // display the current speed 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /oops/Vehicle.java: -------------------------------------------------------------------------------- 1 | package oops; 2 | 3 | public class Vehicle { 4 | String color; 5 | int speed; 6 | 7 | public Vehicle(String color) { 8 | this.color = color; 9 | } 10 | 11 | public void start() { 12 | System.out.println("Started..."); 13 | } 14 | 15 | public void stop() { 16 | System.out.println("Stopped..."); 17 | this.speed = 0; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /oops/myVehicle.java: -------------------------------------------------------------------------------- 1 | package oops; 2 | 3 | public class myVehicle { 4 | public static void main(String[] args) { 5 | Car bmw = new Car("White", "BMW"); 6 | Car maruthi = new Car("Black", "Maruthi"); 7 | 8 | bmw.start(); 9 | bmw.applyAcc(100); 10 | bmw.stop(); 11 | 12 | maruthi.start(); 13 | maruthi.stop(); 14 | } 15 | } 16 | --------------------------------------------------------------------------------