test1 KEY - COP 3330 Exam #1 Summer 2011 Wednesday June 15,...

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

View Full Document Right Arrow Icon
(Question 1 – 20 points (2pts/answer) – True/False Questions: Various Topics) Circle the correct answer. a. A method can be overloaded provided that there are different numbers of parameters or there is some difference in the types of parameters. TRUE FALSE b. Class variables are also known as static variables. TRUE FALSE c. An object’s “state” is stored in instance methods and an object’s “behavior” is represented by instance variables. TRUE FALSE d. Maintainability and efficiency are two of the criteria that are used to define “elegant” software. TRUE FALSE e. The reserved word this allows a reference to be made, within a method, to the object invoking the method. TRUE FALSE f. Multiple inheritance is supported by Java. TRUE FALSE g. A constructor method must have the same name as the class in which it appears. TRUE FALSE h. A method that returns nothing (whose return type is void) cannot contain a return statement. TRUE FALSE i. The + operator is an overloaded operator in Java. TRUE FALSE j. A class method has access to the instance variables in its class TRUE FALSE (Question 2 – 16 points (2 pts/answer) – Tracing Code Execution) 1 COP 3330 – Exam #1 – Summer 2011 Wednesday June 15, 2011 100 points total PRINT YOUR NAME CLEARLY Name: KEY
Background image of page 1

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

View Full DocumentRight Arrow Icon
What will be the output of the following Java program? Put your answers in the spaces provided. ANSWERS: n1.x: n1.y: n2.x: n2.y: n3.x: n3.y: n4.x: n4.y: 2 2 4 1 3 6 8 10 12 public class Num { public int x,y; public Num (int a, int b){ x = a; y = b; }//end class Num public class NumTest { static void f1(int a, int b, Num c, Num d, Num f){ a = b; b = c.y; c = d; d.x = f.x; d.y = f.y; c = f; c.x = 10; c.y = 12; } public static void main(String[] args) { Num n1 = new Num(2,4); Num n2 = new Num(1,3); Num n3 = new Num(5,7); Num n4 = new Num(6,8); f1(n1.x, n1.y, n2, n3, n4); System.out.println(“n1.x: “ + n1.x + “n1.y: “ + n1.y + “n2.x: “ + n2.x + “n2.y: “ + n2.y); System.out.println(“n3.x: “ + n3.x + “n3.y: “ + n3.y + “n4.x: “ + n4.x + “n4.y: “ + n4.y); }//end main }//end class NumTest
Background image of page 2
initial configuration invoke: method f1(n1.x, n1.y, n2, n3, n4); locally: f1(a, b, c, d, f); a = 2, b = 4 original pointers are dashed lines – modified pointers are bold a = b;
Background image of page 3

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

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

This note was uploaded on 07/04/2011 for the course COP 3330 taught by Professor Staff during the Summer '08 term at University of Central Florida.

Page1 / 10

test1 KEY - COP 3330 Exam #1 Summer 2011 Wednesday June 15,...

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

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