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

 Write a Java Program to do the following. a) Create a class Teacher with the field collegeName type String,   

Write a Java Program to do the following. a) Create a class Teacher with the field collegeName type String, designation Type String and a method work(). b) Create a sub class Physics Teacher of Teacher. Which have single field mainSubject of type String and main method. c) Create an object "obj" of PhysicsTeacher inside class Physics Teacher. 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?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure heres a Java program that satisfies the given requirements Teacher class class Teacher String c... 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 Computer Network Questions!