quiz4S09

quiz4S09 - Name _ CMPS 11 Quiz4 This is a closed notes,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Name _______________________ CMPS 11 Quiz4 May 19, 2009 This is a closed notes, closed book exam. THERE ARE MORE QUESTIONS ON THE BACK class ClassOne { int data = 111; public int get() { return data; } public int mystery() { return get()*3; } } class ClassTwo extends ClassOne { int data = 222; public int get() { return data; } } 1. What does the following program print? class Quiz4P1 { public static void main(String[] args) { someFunc(new ClassOne()); } static void someFunc(ClassOne one) { System.out.println(one.get()); System.out.println(one.mystery()); } } 2. What does the following program print? class Quiz4P2 { public static void main(String[] args) { someFunc(new ClassTwo()); } static void someFunc(ClassOne one) { System.out.println(one.get()); System.out.println(one.mystery()); } } 3. What does the following program print? class Quiz4P3 { public static void main(String[] args) { someOtherFunc(new ClassTwo()); } static void someOtherFunc(ClassTwo two) { System.out.println(two.get());
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

quiz4S09 - Name _ CMPS 11 Quiz4 This is a closed notes,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online