├── README.md ├── School.java └── Theatre.java /README.md: -------------------------------------------------------------------------------- 1 | # basic-java-assignments 2 | 3 | I Have included my answers as a java file in this repository. 4 | 5 | Assignment 0: 6 | 7 | 1. Create a class called 'School'. 8 | 2. Have main method in it. 9 | 3. Create an Object called 'schoolObj' inside main method. 10 | 4. Using 'schoolObj', call method called 'test'. 11 | 5. Create method 'test'. 12 | 6. Inside 'test' method, print "Annual exam". 13 | 14 | 15 | Assignment 1: 16 | 1. Create class called 'Theatre'. 17 | 2. Have main method in it. 18 | 3. Create an object called 'rohini_theatre'. 19 | 4. Using 'rohini_theatre', call a method named as 'show'. 20 | 5. For the above method, pass 120, 4 as arguments [show(120,4)]. 21 | 6. Define show(120,4) method. 22 | 7. Name the first argument as ticket_price and second as no_of_persons 23 | 8. Inside show method definition, print the total cost for four persons 24 | -------------------------------------------------------------------------------- /School.java: -------------------------------------------------------------------------------- 1 | public class School{ 2 | public static void main (String [] args) 3 | { 4 | School schoolObj = new School(); 5 | schoolObj.test(); 6 | } 7 | void test() 8 | { 9 | System.out.println("Annual exam"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Theatre.java: -------------------------------------------------------------------------------- 1 | class Theatre{ 2 | public static void main(String [] args) 3 | { 4 | Theatre rohini_theatre = new Theatre(); 5 | rohini_theatre.show(120,4); 6 | } 7 | void show(int a,int b) 8 | { 9 | int ticket_price = a; 10 | int no_of_persons = b; 11 | System.out.println(ticket_price*no_of_persons); 12 | } 13 | } 14 | 15 | --------------------------------------------------------------------------------