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) 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
