


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



CMSC 132 Quiz 1 Worksheet
The first Quiz of the course will be on Wednesday, Sept 7 during your lab (discussion) session. The following list provides more information about the quiz:
The following exercises cover the material to be included in Quiz #1. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with TAs and instructors during office hours.
public class Oven { protected String make;
public void turnOn() { System.out.println("Oven On"); } }
public class Microwave extends Oven { public double power;
public void turnOn() { System.out.println("Micro On"); }
public void turnOn(int thePower) { power = thePower; System.out.println("Micro On with " + power); } }
public static void main(String[] args) {
p.turnOn(10); VALID / INVALID
p.make = "GT"; VALID / INVALID
p.power = 200; VALID / INVALID
m.turnOn(20); VALID / INVALID
Microwave k = (Microwave)m; k.turnOn(200); VALID / INVALID
Microwave.make = "TU"; VALID/ INVALID
Oven.make = "TU"; VALID/ INVALID
Oven.turnOn(); VALID/ INVALID }
Oven v1 = new Microwave(); v1.turnOn();
Microwave v2 = new Oven(); v2.turnOn();
Output:
Output: