Question: Q.1 Write a Java Program to do the following. (Marks:3) a) Create a class Teacher with the field collegeName type String, designation Type String and

 Q.1 Write a Java Program to do the following. (Marks:3) a)

Q.1 Write a Java Program to do the following. (Marks:3) a) Create a class Teacher with the field collegeName type String, designation Type String and a method work(). b) Create a sub class PhysicsTeacher of Teacher. Which have single field mainSubject of type String and main method. c) Create an object "obj" of PhysicsTeacher inside class PhysicsTeacher. Show, how we can call field collegeName, designation and method work() using object "obj". Q.2 Assume that you see the following lines of code: (Marks:2) Device dev = new Printer(); dev.getName(); a) Printer is a subclass of Device, which of these classes must have a definition of method getName for this code to compile? b) if both classes have an implementation of getName, which one will be executed? Q.3 Consider the following interface Vehicle. (Marks:3) interface Vehicle \{ void changeGear(char newGear); void increaseSpeed(int newSpeed); void decreaseSpeed(int newSpeed); 3 a) Create the classes Car and Bus that implements the methods of interface Vehicle. b) Add gear and speed fields in Car and Bus classes. c) changeGear() method sets the gear field by newGear value. d) increaseSpeed() method increases the speed field by newSpeed value. e) decreaseSpeed() method decreases the speed field by newSpeed value. Q.4 Can an abstract class have concrete (non-abstract) methods? Can a concrete class have abstract methods? Can you have an abstract class without abstract methods? Justify your answers. (Marks:2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Q1 Java Program Part a Create a class Teacher java class Teacher String collegeName String designation void work SystemoutprintlnTeaching Part b Creat... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!