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, 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
Sure heres a Java program that satisfies the given requirements Teacher class class Teacher String c... View full answer
Get step-by-step solutions from verified subject matter experts
