332 Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

D

"AbA".compareToIgnoreCase("abC") returns ___________. A. 1 B. 2 C. -1 D. -2 E. 0

B

"abc".compareTo("aba") returns ___________. A. 1 B. 2 C. -1 D. -2 E. 0

Whenever inheritance is used, the subclass must fit into a(n) ____ relationship with the base class.

"is-a"

The format specifier ________ is a placeholder for an int value.

%d

The ____ operator is used to concatenate two strings.

&

B

'3' - '2' + 'm' / 'n' is ______. A. 0 B. 1 C. 2 D. 3

To access the 9th element in an array the ____ index is used.

(8)

Which of the following is the best for generating random integer 0 or 1?

(int)(Math.random() + 0.5)

Which of the following expression yields an integer between 0 and 100, inclusive?

(int)(Math.random()*101)

If a key is not in the list, the binarySearch method returns

-(insertion point +1)

Assume int[] scores = {1, 20, 30, 40, 50}, what value does java.util.Arrays.binarySearch(scores, 3) return?

-2

Suppose array a is int[] a = {1, 2, 3}, what is a[0] - a[2]?

-2

In Java, multidimensional arrays ________.

-are not directly supported. -are implemented as arrays of arrays. -are often used to represent tables of values.

A static method can ________.

-call only other static methods of the same class directly -manipulate only static fields in the same class directly -be called using the class name and a dot (.)

Exceptions can be thrown by ________.

-the Java Virtual Machine -code in a try block -calls from a try block to other methods

Graphical elements called ____ components can be placed on a Windows Form object using the elements in the accompanying figure, when you are designing the user interface.

.NET

The ____ provides tools and processes developers can use to produce and run programs.

.NET Framework

The elements in an integer type array will be initialized to ____.

0

What is the output of the following Java code? int num = 15; while (num > 0) num = num - 3; System.out.println(num);

0

What is the result value of c at the end of the following code segment? int c = 8; c++; ++c; c %= 5;

0

public static void main(String[]args) { int[]list1={1,2,3}; int[]list2={1,2,3}; list2=list1; list1[0]=0; list1[1]=1; list2[2]=2; for(int i=0;i<list2.length; i++) System.out.print(list2[i]+" "); }

0 1 2

public static void main(String[]args) { int[]list1={1,2,3}; int[]list2={1,2,3}; list2=list1; list1[0]=0; list1[1]=1; list2[2]=2; for(int i=0; i<list1.length; i++) System.out.print(list1[i] + " "); }

0 1 2

public static void main(String[]args) { int[]x={0,1,2,3,4,5}; xMethod(x,5); } public static void xMethod(int[]x,int length) { for(int i=0; i<length; i++) System.out.print(" "+x[i]); }

0 1 2 3 4

What is the value of balance after the following code is executed? int balance = 10; while (balance >= 1) { if (balance < 9) break; balance = balance - 9; }

1

What is the value of balance? int balance = 10; while (balance>=1){ if (balance < 9) break; balance = balance - 9;

1

int[][]values = {{3,4,5,1},{33,6,1,2}}; int v=values[0][0]; for(int[] list: values) for(int element: list) if (v>element) v=element; System.out.print(v);

1

public static void main(String[]args) { int[]myList = {1,2,3,4,5,6}; for(int i = myList.length-2;i>=0; i--) myList[i+1]=myList[i]; for(int e: myList) System.out.print(e + " "); }

1 1 2 3 4 5

for (int i =0; i<args.length; i++) System.out.print(args[i] + " "); What is the output, if you run the program using the following? java Test 1 2 3

1 2 3

The following loop displays _______________. for (int i = 1; i <= 10; i++) { System.out.print(i + " "); i++; }

1 3 5 7 9

The following loop displays: for(int i = 1: i <=10;i++) { System.out.print(i + ""); i++; }

1 3 5 7 9

What is the output of the following fragment? for (int i = 0; i < 15; i++) { if (i % 4 == 1) System.out.print(i + " "); }

1 5 9 13

for(int i = 0; i<15; i++){ if (i%4 == 1) System.out.print(i + " ");

1 5 9 13

int count = 0; do{ System.out.println("Welcome to Java"); }while(++count<10);

10

int y = 0; for(int i = 0; i<10; ++i){ y +=1; } System.out.println(y);

10

How many times will the following code print "Welcome to Java"? int count = 0; do { System.out.println("Welcome to Java"); count++; } while (count < 10);

10 times

How many times will the following code print "Welcome to Java"? int count = 0; do { System.out.println("Welcome to Java"); } while (++count < 10);

10 times

How many times will the following code print "Welcome to Java"? int count = 0; do { System.out.println("Welcome to Java"); } while (count++ < 10);

10 times

How many times will the following code print "Welcome to Java"? int count = 0; while (count < 10) { System.out.println("Welcome to Java"); count++; }

10 times

How many times will the following code print "Welcome to Java"? int count = 0; while (count++ < 10) { System.out.println("Welcome to Java"); }

10 times

What is the value in count after the following loop is executed? int count = 0; do { System.out.println("Welcome to Java"); } while (count++ < 9); System.out.println(count);

10 times

Analyze the following code: public class Test { public static void main (String args[]) { int i = 0; for (i = 0; i < 10; i++); System.out.println(i + 4); } }

14

Assume char[][][] x = new char[14][5][16], what are x.length, x[2].length, and x[0][0].length?

14, 5, and 16

int sum = 0; int item = 0; do{ item++; sum +=item; if(sum>4)continue; }while (item<5); System.out.println(sum);

15

what is sum after the following loop terminates? int sum = 0; int item = 0; do { item++; sum += item; if (sum >= 4) continue; } while (item < 5);

15

A Smartphone has ____ softkeys.

2

Assume int[] scores = {1, 20, 30, 40, 50}, what value does java.util.Arrays.binarySearch(scores, 30) return?

2

If the third item in a ComboBox list is selected by the user, the SelectedIndex property of the ComboBox will have the value ____.

2

static void nPrint(String message, int n){ while (n>0){ System.out.print(message); n--; } } What is k after invoking nPrint("A message", k)? int k = 2; nPrint("A message", k);

2

public static void main(String[]args) { int[]x={1,2,3,4,5}; increase(x); int[]y = {1,2,3,4,5}; increase(y[0]); System.out.println(x[0] + " " + y[0]); } public static void increase(int[]x) { for(int i=0; i<x.length; i++) x[i]++; } public static void increase(int y) { y++; }

2 1

int[]list1 = {3,2,1}; int[]list2 = {1,2,3}; list2=list1; list1[0]=0; list1[1]=1; list2[2]=2; for(int i=list2.length-1; i>=0; i--) System.out.print(list2[i] + " ");

2 1 0

int[]myList = {1,2,3,4,5,6}; for(int i=1; i<myList.length; i++) myList[i-1]=myList[i]; for(int e: myList) System.out.print(e + " ");

2 3 4 5 6 6

int[][]matrix = {{1,2,3,4}, {4,5,6,7}, {8,9,10,11}, {12,13,14,15}}; for (int i = 0; i<4; i++) System.out.print(matrix[i][1] + " ");

2 5 9 13

Assume int[][] x = {{1, 2}, {3, 4, 5}, {5, 6, 5, 9}}, what are x[0].length, x[1].length, and x[2].length?

2, 3, and 4

If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, list[1] is

2.0

Use the selectionSort method presented in this section to answer this question. Assume list is {3.1, 3.1, 2.5, 6.4, 2.1}, what is the content of list after the first iteration of the outer loop in the method?

2.1, 3.1, 2.5, 6.4, 3.1

What will be the value of the variable intTotalCount when the following code is executed? For intOuterCount = 1 to 5 For intInnerCount = 1 to 4 intTotalCount +=1 Next Next

20

Visual Studio can be used to create mobile applications for more than ____ different devices from multiple vendors

200

What will be the value of x after the following code is executed? int x = 10; do { x *= 20; } while (x < 5);

200

A Smartphone has a display screen that is ____ in size.

240 x 320 pixels

How many elements are array matrix (int[][] matrix = new int[5][5])?

25

If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, the highest index in array list is

3

Assume int[][] x = {{1, 2}, {3, 4}, {5, 6}}, what are x.length are x[0].length?

3 and 2

int[][]numbers = {{1}, {1,2}, {1,2,3}}; What is numbers.length and what is numbers[1].length?

3,2

public static void main(String[] args) { double [][]m = {{1,2,3}, {1.5,2.5,3.5}, {0.1,0.1,0.1}}; System.out.println(sum(m)); } public static double sum(double[][]m) { double sum = 0; for(int i = 0; i<m.length; i++) sum+=m[i][i]; return sum; }

3.6

Assume int[][][] x = new char[2][5][3], how many elements are in the array?

30

public static void main(String[]args) { int[][]values = {{3,4,5,1}, {33,6,1,2}}; int v = values[0][0]; for(int row=0; row<values.length; row++) for(int column = 0; column<values[row].length; column++) if(v<values[row][column]) v=values[row][column]; System.out.print(v);

33

Assume int[] t = {1, 2, 3, 4}. What is t.length?

4

How many times will the following loop execute? For intCount = 10 To 16 Step 2 'Body of Loop Next

4

double []myList = {1,5,5,5,5,1}; double max = myList[0]; int indexOfMax=0; for(int i=1; i<myList.length;i++) { if(myList[i]>=max) { max=myList[i]; indexOfMax=i; } } System.out.println(indexOfMax);

4

public static void main(String[] args) { int[][][] data = {{{1,2},{3,4}}, {{5,6},{7,8}}}; System.out.print(ttt(data[0])); } public static int ttt(int [][]m) { int v = m[0][0]; for(int i = 0; i<m.length; i++) for (int j = 0; j<m[i].length; j++) if(v<m[i][j]) v=m[i][j]; return v; }

4

int[][]matrix = {{1,2,3,4}, {4,5,6,4,7}, {8,9,10,11}, {12,13,14,15}}; for (int i = 0; i<matrix.length; i++) System.out.print(matrix[i][3] + " ");

4 4 11 15

int [][] matrix = {{1,2,3,4},{4,5,6,7},{8,9,10,11}, {12,13,14,15}}; for(int i=0; i<4; i++) System.out.print(matrix[1][i] + " ");

4 5 6 7

Assume double[][] x = new double[4][5], what are x.length and x[2].length?

4 and 5

Assume double[][][] x = new double[4][5][6], what are x.length, x[2].length, and x[0][0].length?

4, 5, and 6

for (int i = 0;i<10;i++) for (int j = 0; j<i; j++) System.out.println(i*j);

45

int y = 0; for(int i = 0; i<10; ++i){ y +=i; } System.out.println(y);

45

Assume int[][] x = {{1, 2, 3}, {3, 4, 5, 5}, {5, 6}}, what are x.length are x[1].length?

4?

How many elements are in array double[] list = new double[5]?

5

What is the output of the following code? int count; int num = 2; for (count = 1; count < 2; count++) { num = num + 3; System.out.print(num + " "); } System.out.println();

5

int[][][]data = {{{1,2}, {3,4}},{{5,6}, {7,8}}}; System.out.print(data[1][0][0]);

5

public static void main(String[] args) { int [][]values = {{3,4,5,1}, {33,6,1,2}}; for(int row = 0; row<values.length; row++) { System.out.print(m(values[row]) + " "); } } public static int m(int[]list) { int v = list[0]; for(int i = 1; i<list.length; i++) if(v<list[i]) v=list[i]; return v; }

5 33

Assume boolean[][] x = new boolean[5][7], what are x.length and x[2].length?

5 and 7

What is sum after the following loop terminates? int sum = 0; int item = 0; do { item++; sum += item; if (sum > 4) break; } while (item < 5);

6

int sum = 0; int item = 0; do{ item++; sum +=item; if(sum>4)break; }while (item<5); System.out.println(sum);

6

How many times will the following code print "Welcome to Java"? int count = 0; while (count < 8) { System.out.println("Welcome to Java"); count++; }//end of while loop

8

B

A Java character is stored in __________. A. one byte B. two bytes C. three bytes D. four bytes

Given the Java statement number1 = input.nextInt(); in which number1 is an int and input is a Scanner, which of the following occurs if the user does not enter a valid int value?

A runtime logic error occurs.

Which statement best describes the relationship between superclass and subclass types?

A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

How many times is the println statement executed? (one of the answers) for (int i = 0; i < 10; i++) for (int j = 0; j < i; j++) System.out.println(i * j)

A. 45

Analyze the following code. int count = 0; while (count < 100) { // Point A System.out.println("Welcome to Java!"); count++; // Point B } // Point C

A. count < 100 is always true at Point C C. count < 100 is always true at Point A D. count < 100 is always true at Point B

ABCD

A. if (s.startsWith("Java")) ... B. if (s.indexOf("Java") == 0) ... C. if (s.substring(0, 4).equals("Java")) ... D. if (s.charAt(0) == 'J' && s.charAt(1) == 'a' && s.charAt(2) == 'v' && s.charAt(3) == 'a') ...

Which of the following loops prints "Welcome to Java" 10 times? A: for (int count = 1; count <= 10; count++) { System.out.println("Welcome to Java"); } B: for (int count = 0; count < 10; count++) { System.out.println("Welcome to Java"); } C: for (int count = 1; count < 10; count++) { System.out.println("Welcome to Java"); } D: for (int count = 0; count <= 10; count++) { System.out.println("Welcome to Java"); }

AB

A set of prewritten classes called ____ allows you to access data stored in a database.

ADO.NET 3.5

The hot key for a menu item can be activated with the keyboard by pressing the ____ key and the hot key at the same time.

ALT

8.5 Q4: What happens when this is used in a constructor's body to call another constructor of the same class if that call is not the first statement in the constructor? a. a. A compilation error occurs. b. b. A runtime error occurs. c. c. A logic error occurs. d. d. Nothing happens. The program compiles and runs.

ANS: a. A compilation error occurs.

8.3 Q2: Which of the following statements is true? a. a. Methods and instance variables can both be either public or private. b. b. Information hiding is achieved by restricting access to class members via keyword public. c. c. The private members of a class are directly accessible to the client of a class. d. d. None of the above is true.

ANS: a. Methods and instance variables can both be either public or private.

8.6 Q1: Which statement is false? a. a. The compiler always creates a default constructor for a class. b. b. If a class's constructors all require arguments and a program attempts to call a no-argument constructor to initialize an object of the class, a compilation error occurs. c. c. A constructor can be called with no arguments only if the class does not have any constructors or if the class has a public no-argument constructor. d. d. None of the above.

ANS: a. The compiler always creates a default constructor for a class.

8.16 Q6: The import declaration import *; ________. a. a. causes a compilation error. b. b. imports all classes in the library. c. c. imports the default classes in the library. d. d. imports the classes in package java.lang.

ANS: a. causes a compilation error.

8.9 Q1: enum types are implicitly ________ and enum constants are implicitly ________. a. a. final, static. b. b. static, static. c. c. static, final. d. d. final, final. .

ANS: a. final, static

8.9 Q3: Which method returns an array of the enum's constants? a. a. values. b. b. getValues. c. c. constants. d. d. getConstants.

ANS: a. values.

8.16 Q2: A class within a package must be declared public if a. a. It will be used only by other classes in the same package. b. b. It will be used by classes that are not in the same package. c. c. It is in the same directory as the other classes in the package. d. d. It has a unique name.

ANS: b. It will be used by classes that are not in the same package. Classes outside the package cannot use a class if the class is not declared public.

8.2 Q2: The static method ________ of class String returns a formatted String. a. a. printf. b. b. format. c. c. formatString. d. d. toFormatString.

ANS: b. format.

8.8 Q1: Composition is sometimes referred to as a(n) ________. a. a. is-a relationship. b. b. has-a relationship. c. c. many-in-one relationship. d. d. one-to-many relationship.

ANS: b. has-a relationship.

8.12 Q1: Which syntax imports all static members of class Math? a. a. static import java.lang.Math.*. b. b. import static java.lang.Math.*. c. c. static import java.lang.Math. d. d. import static java.lang.Math.

ANS: b. import static java.lang.Math.*.

8.5 Q3: A programmer-defined constructor that has no arguments is called a(n) ________. a. a. empty constructor. b. b. no-argument constructor. c. c. default constructor. d. d. null constructor.

ANS: b. no-argument constructor.

8.5 Q5: When implementing a method, use the class's set and get methods to access the class's ________ data. a. a. public. b. b. private. c. c. protected. d. d. All of the above.

ANS: b. private.

8.16 Q7: The classpath consists of a list of directories or archive files, each separated by a ________ on Windows or a ________ on UNIX/Linux/Max OS X. a. a. colon (:), semicolon (;). b. b. semicolon (;), colon (:). c. c. comma (,), semicolon (;). d. d. semicolon (;), comma (,).

ANS: b. semicolon (;), colon (:).

8.16 Q4: When compiling a class in a package, the javac command-line option ________ causes the javac compiler to create appropriate directories based on the class's package declaration. a. a. -p. b. b. -a. c. c. -d. d. d. -dir.

ANS: c. -d.

8.4 Q1: When should a program explicitly use the this reference? a. a. Accessing a private variable. b. b. Accessing a public variable. c. c. Accessing a local variable. d. d. Accessing a field that is shadowed by a local variable.

ANS: c. Accessing a field that is shadowed by a local variable.

8.9 Q2: Which statement is false? a. a. An enum declaration is a comma-separated list of enum constants and may optionally include other components of traditional classes, such as constructors, fields and methods. b. b. Any attempt to create an object of an enum type with operator new results in a compilation error. c. c. An enum constructor cannot be overloaded. d. d. An enum constructor can specify any number of parameters.

ANS: c. An enum constructor cannot be overloaded.

8.13 Q1: Instance variables declared final do not or cannot: a. a. Cause syntax errors if used as a left-hand value. b. b. Be initialized. c. c. Be modified. d. d. None of the above.

ANS: c. Be modified.

8.17 Q1: When no access modifier is specified for a method or variable, the method or variable: a. a. Is public. b. b. Is private. c. c. Has package access. d. d. Is static.

ANS: c. Has package access.

8.10 Q1: Which of the following is false? a. a. Method finalize does not take parameters and has return type void. b. b. Memory leaks using Java are rare because of automatic garbage collection. c. c. Objects are marked for garbage collection by method finalize. d. d. The garbage collector reclaims unused memory.

ANS: c. Objects are marked for garbage collection by method finalize. (Objects are marked for garbage collection when there are no more references to the object).

Q1: Which of the following should usually be private? a. a. Methods. b. b. Constructors. c. c. Variables (or fields). d. d. All of the above. ANS: c. Variables (or fields).

ANS: c. Variables (or fields).

8.7 Q1: Set methods are also commonly called ________ methods and get methods are also commonly called ________ methods. a. a. query, mutator. b. b. accessor, mutator. c. c. mutator, accessor. d. d. query, accessor.

ANS: c. mutator, accessor.

8.2 Q1: The _________ of a class are also called the public services or the public interface that the class provides to its clients. a. a. public constructors. b. b. public instance variables. c. c. public methods. d. d. All of the above.

ANS: c. public methods.

8.5 Q1: A constructor cannot: a. a. be overloaded. b. b. initialize variables to their defaults. c. c. specify return types or return values. d. d. have the same name as the class.

ANS: c. specify return types or return values.

8.2 Q3: Which statement is false? a. a. The actual data representation used within the class is of no concern to the class's clients. b. b. Clients generally care about what the class does but not how the class does it. c. c. Clients are usually involved in a class's implementation. d. d. Hiding the implementation reduces the possibility that clients will become dependent on class-implementation details.

ANS: c: Clients are usually involved in a class's implementation

8.16 Q1: A package is: a. a. A directory structure used to organize classes and interfaces. b. b. A mechanism for software reuse. c. c. A group of related classes and interfaces. d. d. All of the above.

ANS: d. All of the above.

8.4 Q2: Having a this reference allows: a. a. a method to refer explicitly to the instance variables and other methods of the object on which the method was called. b. b. a method to refer implicitly to the instance variables and other methods of the object on which the method was called. c. c. an object to reference itself. d. d. All of the above.

ANS: d. All of the above.

8.7 Q3: Using public set methods provides data integrity if: a. a. The instance variables are public. b. b. The instance variables are private. c. c. The methods perform validity checking. d. d. Both b and c.

ANS: d. Both b and c.

8.5 Q2: Constructors: a. a. Initialize instance variables. b. b. When overloaded, can have identical argument lists. c. c. When overloaded, are selected by number, types and order of types of parameters. d. d. a and c.

ANS: d. a and c.

8.11 Q1: Static class variables: a. a. are final. b. b. are public. c. c. are private. d. d. are shared by all objects of a class.

ANS: d. are shared by all objects of a class.

8.16 Q8: By default, the classpath consists only of the ________. However, the classpath can be modified by providing the ________ option to the javac compiler. a. a. root directory of the package, -d. b. b. current directory, -d. c. c. root directory of the package, -classpath. d. d. current directory, -classpath.

ANS: d. current directory, -classpath.

8.13 Q2: A final field should also be declared ________ if it is initialized in its declaration. a. a. private. b. b. public. c. c. protected. d. d. static.

ANS: d. static.

8.16 Q5: The import declaration import java.util.*; is known as a ________. a. a. single-type-import declaration. b. b. all-type-import declaration. c. c. multiple-import declaration. d. d. type-import-on-demand declaration.

ANS: d. type-import-on-demand declaration.

When must a program explicitly use the this reference?

Accessing an instance variable that is shadowed by a local variable.

As shown in the accompanying figure, Visual Basic 2008 contains a(n) ____ Tag that allows you to create a full standard menu bar commonly provided in Windows programs.

Action

To add 0.01 + 0.02 + ... + 1.00, what order should you use to add the numbers to get better accuracy?

Add 0.01, 0.02, ..., 1.00 in this order to a sum variable whose initial value is 0.

The filename for the public class that begins with public class Addition must be

Addition.java

int [][] matrix = new int[5][5]; for(int column = 0; column<matrix[4].length; column++) matrix[4][column] = 10;

After the loop, the last row of matrix 10, 10, 10, 10, 10.

Which of the following can be used in a switch statement in the expression after keyword case? A. a constant integral expression. B. a character constant. C. a String D. an enumeration constant.

All

Which of the following statements is true? Performing a task in a program requires a method. A method houses the program statements that actually perform its tasks The method hides its statements from its user, just as the accelerator pedal of a car hides from the driver the mechanisms of making the car go faster. All of the above.

All of the above.

AB

An int variable can hold __________. A. 'x' B. 120 C. 120.0 D. "x" E. "120"

A syntax error, because column is not defined.

Analyze the following code: int[][] matrix = new int[5][5]; for (int column = 0; column < matrix[4].length; column++) matrix[4][column] = 10;

A syntax error, because column is not defined.

Analyze the following code: int[][] matrix = new int[5][5]; for (int column = 0; column < matrix[4].length; column++); matrix[4][column] = 10;

The program runs and displays x[2][2] is false.

Analyze the following code: public class Test { public static void main(String[] args) { boolean[][] x = new boolean[3][]; x[0] = new boolean[1]; x[1] = new boolean[2]; x[2] = new boolean[3]; System.out.println("x[2][2] is " + x[2][2]); } }

The ____ exception type occurs when a variable with no value is passed to a procedure.

ArgumentNullException

To apply the sort procedure to an array called intAges, use the syntax ____.

Array.Sort(intAges)

When defining a variable to be used to hold textual information containing multiple characters, the declaration statement should have ____ at the end of the statement.

As String

The ____ information screen contains values that include the program name, description, company, product, and copyright date.

Assembly

5 and 7

Assume boolean[][] x = new boolean[5][7], what are x.length and x[2].length?

x[4][6]

Assume boolean[][] x = new boolean[5][7], what is the index variable for the element at the last row and last column in array x?

4 and 5

Assume double[][] x = new double[4][5], what are x.length and x[2].length?

6, 5, and 4

Assume double[][][] x = new double[4][5][6], what are x.length, x[2].length, and x[0][0].length?

2, 3, and 4

Assume int[][] x = {{1, 2}, {3, 4, 5}, {5, 6, 5, 9}}, what are x[0].length, x[1].length, and x[2].length?

3 and 2

Assume int[][] x = {{1, 2}, {3, 4}, {5, 6}}, what are x.length and x[0].length?

30

Assume int[][][] x = new char[2][5][3], how many elements are in the array?

The ____ property specifies the location of an image to be displayed directly on the form.

BackgroundImage

The ____method repeatedly divides the search interval of an array in half to reduce searching time dramatically.

BinarySearch

The IsNumeric function will return a(n) ____ type value.

Boolean

To return multiple variables from a Function procedure, arguments passed ____ must be used.

ByRef

The ____ object shows the days organized by month relevant to the year.

Calendar

The ____ option of the SizeMode property of the PictureBox object does not change the size of the image or the size of the PictureBox object, and places the image in the center of the PictureBox object.

CenterImage

The character C is the literal type character for the ____ data type.

Char

The Label object appears in the ____ category in the Toolbox.

Common Controls

Which of the following statements is true? Interpreted programs run faster than compiled programs. Compilers translate high-level language programs into machine language programs. Interpreter programs typically use machine language as input.

Compilers translate high-level language programs into machine language programs.

3, 2

Consider the following statements: int[][] numbers = {{1}, {1, 2}, {1, 2, 3}}; What is numbers.length and what is numbers[1].length?

Which of the following can be an argument to a method?

Constants Variables Expressions

The ____ property contains the name of the object to be validated when using any of the validation objects on a Web form.

ControlToValidate

A ____ object is a temporary cache storage for data retrieved from a data source.

DataSet

A(n) ____ object is a temporary cache storage for data retrieved from a data source.

DataSet

A ____ object is used to hold data that is retrieved from a database via the OleDbDataAdapter connection.

DataTable

When in break mode, you can use ____ to examine the value of variables.

DataTips

A user can permanently remove a database record by clicking the ____ button on the navigation toolbar.

Delete

A ____ Exception occurs when code attempts to divide a number by zero.

Divide by Zero

What does the expression x %= 10 do?

Divides x by 10 and stores the remainder in x.

If ____ appears as the first line of a loop, the loop is a top-controlled Do loop that will execute as long as a condition remains true.

Do While

____ is the concept of separating processing and hiding data within specific classes.

Encapsulation

A Case Else statement is required in a Select Case structure.

False

A DataSet permanently stores database data in the application.

False

A Finally statement is required after each Catch block in a Try-Catch structure to execute any necessary clean-up code.

False

A Label object can only contain one line of text.

False

A RadioButton's Selected property will indicate if the radio button has been selected by the user.

False

A Short data type is used for a very short string value of 10 bytes or less.

False

A Smartphone application uses the same Form object emulator in Visual Basic as a Windows application.

False

A Smartphone has a touch screen.

False

A Web page that allows users to enter information on a Web form is considered a static Web page.

False

A class can only be used in one program for one purpose.

False

A code handler is a section of the program that handles user actions by executing code.

False

A constructor must be named using the statement Public Sub Constructor.

False

A database can contain only one record.

False

A database that is to be accessed by a program must reside on a local hard drive.

False

A graphical user interface (GUI) is a special device for communicating with a user.

False

A hot key in a menu name must be the first letter.

False

A password cannot be included in a connection string.

False

A procedure that does not return a value is called a function.

False

A program can write data, but it cannot save data on disk.

False

A property identifies a value required by a procedure that must be passed into the procedure when it is called.

False

A set of braces at the end of a statement indicates that it is a procedure call statement.

False

A top-controlled loop is always executed at least once.

False

A user cannot delete a record from a database table using the BindingNavigator control.

False

A variable defined between the Then keyword and the Else keyword in an If...Then...Else structure can be referenced from within the Else section of the structure.

False

ADO.NET 3.5 is a programming framework used to build Web applications on a Web server.

False

ADO.NET 3.5 is not part of the .NET Framework 3.5.

False

ASP.NET 3.5 has no way of displaying a full screen view of the Web page as it is being designed.

False

All Smartphones use the Unix platform.

False

All Visual Basic arrays are considered static arrays.

False

An End Case statement is used to terminate a Select Case structure.

False

An array declared within a procedure is accessible outside that procedure.

False

By default, a text box will display as many lines of text as the user enters.

False

By setting the Resize property for a Button object to True, the Button object will automatically expand or contract to accommodate the amount of text entered in the Text property.

False

Changing the value of the Enabled property of an object in code statements can be used to make an object appear on the form during program execution.

False

Char variables can be used in arithmetic operations.

False

Computer hardware will perform its tasks automatically, regardless of whether a software program is running or not.

False

Computer programs can be written in standard English.

False

Concatenation is a major contributor to reliable and robust programs.

False

Data can be input on a Smartphone using a stylus on the touch screen.

False

Data cannot be passed into an object when it is being instantiated.

False

Data must be placed in the CPU in order to be processed.

False

If a variable is passed ByVal and the value of its argument is changed, the initial variable will change as well.

False

If the TextLength property of a textbox is less than 0, it indicates that the textbox contains only a single character.

False

In a Smartphone environment, a ComboBox object works in the same manner as it does in the Windows environment.

False

In a Web service application, a Do-Until block should be used to catch an exception that could occur if the program cannot connect to the Web service.

False

In a three-tier architecture for a Web application, the Web form and Web page constitute the persistence tier.

False

In an If...Then statement, the If keyword should appear on the first line with the conditional expression, and the Then keyword should appear on the second line.

False

In an assignment statement, the value appearing on the right of the equal sign receives the value of the object appearing to the left of the equal sign.

False

In applications that include multiple forms, it is best to declare as few Private variables as possible.

False

In order for the computer to execute a program, or carry out the instructions in the program, only the data must be placed in the computer's random access memory (RAM).

False

In order to run a program, it first must be executed.

False

In string comparison, a number is more than an uppercase letter.

False

Instructions to the user can be placed in the GUI property of a ComboBox.

False

Integer variables can be used to store fractional values.

False

It is the ability of a computer to perform arithmetic operations that separates it from other types of calculating devices.

False

Like a PDA, the Smartphone has a built-in input panel.

False

MOD operations occur before any other arithmetic operations.

False

MenuStrip objects can be placed along any edge of the form, depending on which side is closer to the mouse pointer.

False

Only one argument can be passed to a procedure.

False

Only one breakpoint can be set in a program, as shown in the accompanying figure.

False

Only one condition can be tested in an If statement.

False

Only six different types of exceptions can occur in a Visual Basic program.

False

Panel objects may have captions and scroll bars.

False

Statements outside a base class and its subclasses can reference variables declared in the base class with Protected access.

False

String data types can be used in arithmetic operations.

False

The & key on a Smartphone is used to enter a Space character.

False

The AutoSize attribute of the SizeMode property of a PictureBox object may cause distortion of an image.

False

The CancelButton property of the Form object allows you to specify which button is activated when the CTRL key on the keyboard is pressed.

False

The Caption property is used to set the contents of the title bar of a Windows Form object.

False

The CompareValidator object on a Web form can be used only to compare the value of one object to the value of another object.

False

The DataSet object is not part of the ADO.NET 3.5 architecture.

False

The Disabled property controls whether an object can trigger an event.

False

The Disconnect command should be used to disconnect the program from a database.

False

The Elements property of a ComboBox contains the choices available to the ComboBox.

False

The MessageBox commands on a Smartphone device are displayed the same as they are in a Windows environment.

False

The OleDbDataAdapter consists solely of a path statement to connect to the database.

False

The RegularExpressionValidator is used to check if data entered by the user is within a specified numeric range.

False

The Selected property of a ListBox object identifies which item in the ListBox has been selected.

False

The Show procedure of a Form object loads a form as modal.

False

The Smartphone Toolbox includes the Checkbox, ComboBox, and Button objects.

False

The Text property of a TextBox object cannot be blank in a Web form.

False

The Try-Catch block structure cannot be used in a Smartphone application's code.

False

The ampersand character at the end of a line in the code editor indicates that the line of code continues on the next line.

False

The following for loop executes 21 times. (Assume all variables are properly declared.) for (i = 1; i <= 20; i = i + 1) System.out.println(i);

False

The keywords End SubProcedure signifies the end of a Sub procedure.

False

The only valid procedures are the prewritten procedures included in Visual Studio 2008.

False

The output of the Java code, assuming that all variables are properly declared, is 32. num = 10; while (num <= 32) num = num + 5; System.out.println(num);

False

The output of the Java code, assuming that all variables are properly declared, is: 2 3 4 5 6. n = 2; while (n >= 6) { System.out.print(n + " "); n++; } System.out.println();

False

The prefix ole is used for an OleDbDataAdapter.

False

The process of creating an object from a class template is called generation.

False

The set of instructions that directs a computer to perform tasks is called computer hardware.

False

The text that appears in the title of a Web form is stored in the Web form's Caption property.

False

To change the contents of the text that appears on the face of a Button object, you must use the Caption property.

False

Visual Basic cannot be used to develop programs for devices other than personal computers.

False

Visual Basic will automatically trim off extra spaces from the beginning and end of a string.

False

Visual Studio 2008 displays a pop-up message in the corner of the work area whenever it detects an error in your code.

False

Visual Studio 2008 does not contain a method for printing code.

False

Web services can only be called from standard Windows applications.

False

When a Label object on a Windows Form object is selected, it has a red border.

False

When a subclass is instantiated, only the subclass's constructor is executed.

False

When an active server page is requested, both the ASP.NET 3.5 code for the server and the HTML code for the client are sent to the client.

False

When an array is initialized, no default values are automatically assigned to the elements.

False

When closing the Pocket PC emulator, it is important to save the emulator state to ensure the proper functioning of the code when run again after changes have been made.

False

When comparing two data values in Visual Basic, both values must be the same data type.

False

When creating tables in a database, for coding purposes the table name may contain spaces.

False

When nesting loops, the variable in the outer loop changes more frequently.

False

When the SelectedIndex property of a ComboBox has the value of 0, it indicates that no selection was made by the user.

False

When the Toolbox is in Dockable mode, it cannot be moved.

False

When using inheritance, a subclass cannot use the procedures within the base class.

False

When using the BindingNavigator control in an application, the user may only use the arrow navigation buttons to move throughout the data in the associated table.

False

When using the RangeValidator control, if the Type property is not specified, it will be selected automatically to produce the best result.

False

Will the following program terminate? int balance = 10; while (true) { if (balance < 9) continue; balance = balance - 9; }

False

You can use the Text property of a Label object to change the size and appearance of the text.

False

You should match a light BackColor with a light ForeColor property for the best usability.

False

In a Try-Catch structure, the ____ keyword precedes code that will always execute regardless of whether any exception occurred.

Finally

You can change the size or appearance of the text shown in a Label object by using the ____ property.

Font

The ____ loop stops when the loop has processed every element in an array.

For Each

The ____ property of a GUI object controls the color of text that appears in the object.

ForeColor

The ____ exception type occurs when a variable is converted to another data type that is not possible.

FormatException

An array can be passed as an argument to a(n) ____ procedure.

Function

The name m represents a two-dimensional array of 30 int values

Given the following declaration: int[][] m = new int[5][6]; Which of the following statements is true?

When no access modifier is specified for a method or variable, the method or variable:

Has package access

Which is the output of the following statements? System.out.print( "Hello "); System.out.println( "World" );

Hello World

The ____ property of a Button object contains the name of the button.

ID

When you are creating a Web form, you name objects using the ____ property.

Id

Use the ____ statement to execute one set of instructions if the condition is true, and another set of instructions if the condition is false.

If...Then...Else

The ____ function provides a dialog box that asks the user for input and provides an input area.

InputBox

A variable that will be used to contain only whole numbers should be declared as a(n) ____ data type.

Integer

____ comments appear at the beginning of the program, and contain the developer's name, the date, and the purpose of the program.

Introductory

When relational operators are used in a Case statement within a Select Case structure, the keyword ____ must be used with the relational operator.

Is

The ____ function can be used to test if data entered by the user is numeric.

IsNumeric

Which of the following statements about Java Class Libraries if false? Java class libraries are not portable. An advantage of using Java class libraries is saving the effort of designing, developing and testing new classes. Java class libraries are also known as Java APIs (Application Programming Interfaces). Java class libraries consist of classes that consist of methods that perform tasks.

Java class libraries are not portable.

The ____ object is used to display a message or put a name on an item in a window.

Label

A(n) ____ object displays a collection of items, or values, with one item per line.

ListBox

____ is the last phase of the program development life cycle.

Maintaining the program

B

Math.asin(0.5) returns _______. A. 30 B. Math.toRadians(30) C. Math.PI / 4 D. Math.PI / 2

A

Math.sin(Math.PI) returns _______. A. 0.0 B. 1.0 C. 0.5 D. 0.4

When you type the word ____ followed by a period in the code editor, IntelliSense displays a list of all the entries, including all the objects that can be specified in the statement.

Me

____ is the default setting for the buttons that will be displayed in a message box like the one in the accompanying figure.

MessageBoxButtons.OKOnly

The first in creating a report is to drag the ____ object from the Toolbox onto the page in the div control.

MicrosoftReportViewer

The ____ property of a RangeValidator control on a Web form contains the smallest acceptable value of the range.

MinimumValue

In a Windows application, the property for naming an object is the ____ property.

Name

A constructor procedure is identified by the keyword ____.

New

You can click ____ on a Smartphone screen.

None of the above

Which of the following statements is true? The code in a finally block is executed only if an exception occurs. The code in a finally block is executed only if an exception does not occur. The code in a finally block is executed only if there are no catch blocks

None of the above are true.

C

Note that the Unicode for character A is 65. The expression "A" + 1 evaluates to ________. A. 66 B. B C. A1 D. Illegal expression

A

Note that the Unicode for character A is 65. The expression 'A' + 1 evaluates to ________. A. 66 B. B C. A1 D. Illegal expression

The ____ exception type occurs when a procedure is called and the result is not possible.

NullReferenceException

The ____ is a bridge created by the Database Wizard between the DataSet and the database that contains the data.

OleDbDataAdapter

The ____ exception type occurs when a value exceeds its assigned data type.

OverflowException

Overriding a method differs from overloading a method because:

Overridden methods have the same signature.

A procedure in a subclass that has the same name as a procedure in its base class must be declared in the subclass with the keyword ____.

Overrides

As shown in the accompanying figure, the ____ keyword will save existing data when resizing an array to a larger size.

Preserve

In applications that include multiple forms, it is best to declare every variable as a ____ variable unless the variable is used in multiple Form objects.

Private

The characteristics of GUI controls such as buttons and text boxes can be set using the ____ window in the Visual Studio IDE.

Properties

____ are used to control the color, size, name, and position on the screen of the GUI components.

Properties

Visual Basic contains ____ tools that are used to design a program quickly.

RAD

The ____ validation control should be used to ensure that the user enters a value between 1 and 100.

RangeValidator

The ____ keyword is used to change the number of elements in an array.

ReDim

The Microsoft ____ tool provides a fast and productive way to create and integrate presentation-quality reports without leaving the familiar Visual Basic development environment.

ReportViewer

Consider the class below: public class Test { public static void main(String[] args) { int[] a = {99, 22, 11, 3, 11, 55, 44, 88, 2, -3}; int result = 0; for (int i = 0; i < a.length; i++) { if (a[i] > 30) result += a[i]; } System.out.printf("Result is: %d%n", result); } } The output of this Java program will be:

Result is: 286.

The DataTable object can be used to access individual fields within a database by using the ____ procedure.

Rows

In the accompanying figure, clicking the Ellipsis button at the end of the Image property of the PictureBox object will display the ____ dialog box.

Select Resource

The ____ property of the Calendar object references the date the user clicked in the Calendar object.

SelectedDate

The ____ event is triggered when the selection of a ComboBox object is changed.

SelectedIndexChanged

3.6

Show the printout of the following code. public class Test { public static void main(String[] args) { double[][] m = {{1, 2, 3}, {1.5, 2.5, 3.5}, {0.1, 0.1, 0.1}}; System.out.println(sum(m)); } public static double sum(double[][] m) { double sum = 0; for (int i = 0; i < m.length; i++) sum += m[i][i]; return sum; } }

Command lines placed after the ____ method call are not executed until the second Form object is closed.

ShowDialog

The ____ property of a Windows Form object can be used to change the width of the form.

Size

A(n) ____ is a cell phone that can connect to the Internet and run mobile applications.

Smartphone

The array ____ procedure is used to organize elements in an array according to their values.

Sort

Which of the following is not a primitive type? char float String int

String

Which correctly creates an array of five empty Strings?

String[] a = {"", "", "", "", ""};

AD

Suppose Character x = new Character('a'), __________________ returns true. A. x.equals(new Character('a')) B. x.compareToIgnoreCase('A') C. x.equalsIgnoreCase('A') D. x.equals('a') E. x.equals("a")

C

Suppose x is a char variable with a value 'b'. What is the output of the statement System.out.println(++x)? A. a B. b C. c D. d

Which item in the accompanying figure is a processing device?

System Unit

The ________ method copies the sourceArray to the targetArray.

System.arraycopy(sourceArray, 0, targetArray, 0, sourceArray.length);

The ____ property of a Label object can be used to change the contents of the Label object.

Text

By default, the Data Sources window displays each table item as a ____ object.

TextBox

The ToolStrip control used for navigating through database records is called the BindingToolStrip.

The ToolStrip control used for navigating through database records is called the BindingToolStrip.

D

The __________ method parses a string s to a double value. A. double.parseDouble(s); B. Double.parsedouble(s); C. double.parse(s); D. Double.parseDouble(s);

int [] list = new int [10]

The array variable list contains a memory address that refers to an array of 10 int values.

Which of the following statements about a do...while repetition statement is true?

The body of a do...while loop is always executed at least once.

Which of the following is true about a while loop?

The body of the loop may not execute at all.

Which of the following statements about the break statement is false? The break statement is used to exit a repetition structure early and continue execution after the loop. A break statement can only break out of an immediately enclosing while, for, do...while or switch statement. The break statement, when executed in a while, for or do...while, skips the remaining statements in the loop body and proceeds with the next iteration of the loop. Common uses of the break statement are to escape early from a loop or to skip the remainder of a switch.

The break statement, when executed in a while, for or do...while, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.

int[]lsit = new int[5]; list = new int[6];

The code has compile errors because the variable list cannot be changed once it is assigned.

int[][]m = new int[5][6]; Which is true?

The name m represents a two-dimensional array of 30 int values.

public class Exam1 { public static void main(String[] args) { System.out.println(max(1,2)); } public static double max (int num1, double num2) { System.out.println("max(int,double) is invoked"); if (num1>num2) return num1; else return num2; } public static double max (double num1, int num2) { System.out.println("max(double,int) is invoked"); if(num1>num2) return num1; else return num2; } }

The program cannot compile because the compiler cannot determine which max method should be invoked.

double[]x = new double[]{1,2,3}; System.out.println("Value is " + x[1]);

The program compiles and runs fine and the output "Value is 2.0" is printed.

double[]x=new double[]{1,2,3}; System.out.println("Value is " + x[1]);

The program compiles and runs fine and the output "Value is 2.0" is printed.

Analyze the following code. double sum = 0; for (double d = 0; d < 10; sum += sum + d) { d += 0.1; }

The program compiles and runs fine.

Analyze the following code: import java.util.Scanner; public class Test { public static void main(String[] args) { int sum = 0; for (int i = 0; i < 100000; i++) { Scanner input = new Scanner(System.in); sum += input.nextInt(); } } }

The program compiles and runs, but it is not efficient and unnecessary to execute the Scanner input = new Scanner(System.in); statement inside the loop. You should move the statement before the loop.

int[]x={1,2,3,4}; int[]y=x; x=new int[2]; for(int i =0; i<x.length; i++) System.out.print(x[i] + " ");

The program displays 0 0

int[]a = new int[4]; a[1]=1; a = new int [2]; System.out.println("a[1] is " +a[1]);

The program displays a[1] is 0.

public class Exam1 { public static void main(String[] args) { System.out.println(xmethod(5)); } public static int xmethod (int n, long t){ System.out.println("int"); return n; } public static long xmethod(long n){ System.out.println("long"); return n; } }

The program displays long followed by 5.

double sum = 0; for (double d = 0; d < 10;) {d += 0.1; sum+=sum+d; }

The program has a compile error because the adjustment is missing in the for loop.

public class Exam1 { public static void main(String[] args) { System.out.println(m(2)); } public static int m (int num) { return num; } public static void m (int num) { System.out.println(num); } }

The program has a compile error because the two methods m have the same signature.

public static void main(String[]args) { xMethod(new double[]{3,3}); xMethod(new double[5]); xMethod(new double[3]{1,2,3}); } public static void xMethod(double[]a) { System.out.println(a.length); }

The program has a compile error because xMethod(new double[3]{1, 2, 3}) is incorrect.

final int[]x={1,2,3,4}; int[]y=x; x=new int [2]; for(int i=0; i<y.length; i++) System.out.print(y[i] + " ");

The program has a compile error on the statement x = new int[2], because x is final and cannot be changed.

int []x=new int[5]; int i; for(i=0; i<x.length; i++) x[i]=i; System.out.println(x[i]);

The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException.

public static void main(String[]args) { int[]x=new int[5]; for(int i=0; i<x.length;i++) x[i]=i; System.out.println(x[i]); }

The program has a syntax error because i is not defined in the last statement in the main method.

double sum = 0; double d = 0; while(d != 10.0){ d +=.0; sum += sum +d;

The program may not stop because of the phenomenon referred to as numerical inaccuracy for operating with floating-point numbers.

int[][]values = {{3,4,5,1}, {33,6,1,2}}; for(int row = 0; row<values.length; row++) { java.util.Arrays.sort(values[row]); for(int column = 0; column<values[row].length; column++) System.out.print(values[row][column] + " "); System.out.println(); }

The program prints two rows 1 3 4 5 followed by 1 2 6 33

public static void main(String[]args) { int[]x = new int[3]; System.out.println("x[0] is " + x[0]); }

The program runs fine and displays x[0] is 0.

D

The statement System.out.printf("%10s", 123456) outputs ___________. (Note: * represents a space) A. 123456**** B. 23456***** C. 12345***** D. ****123456

D

The statement System.out.printf("%3.1e", 1234.56) outputs ___________. A. 0.1e+04 B. 0.123456e+04 C. 0.123e+04 D. 1.2e+03 E. 1.23+03

E

The statement System.out.printf("%3.1f", 1234.56) outputs ___________. A. 123.4 B. 123.5 C. 1234.5 D. 1234.56 E. 1234.6

C

The statement System.out.printf("%5d", 123456) outputs ___________. A. 12345 B. 23456 C. 123456 D. 12345.6

Consider the code segment below. Which of the following statements is false? int[] g; g = new int[23];

The value of g[3] is -1.

What is output by the following Java code segment? int temp = 180; while (temp != 80) { if (temp > 90) { System.out.print("This porridge is too hot! "); // cool down temp = temp - (temp > 150 ? 100 : 20); } else { if (temp < 70) { System.out.print("This porridge is too cold! "); // warm up temp = temp + (temp < 50 ? 30 : 20); } } } if (temp == 80) System.out.println("This porridge is just right!");

This porridge is too hot! This porridge is just right!

To specify a continuous range of values to be tested in a Case statement within a Select Case structure, the word ____ must be used.

To

ACE

To check if a string s contains the suffix "Java", you may write A. if (s.endsWith("Java")) ... B. if (s.lastIndexOf("Java") >= 0) ... C. if (s.substring(s.length() - 4).equals("Java")) ... D. if (s.substring(s.length() - 5).equals("Java")) ... E. if (s.charAt(s.length() - 4) == 'J' && s.charAt(s.length() - 3) == 'a' && s.charAt(s.length() - 2) == 'v' && s.charAt(s.length() - 1) == 'a') ...

A

To obtain the arc sine of 0.5, use _______. A. Math.asin(0.5) B. Math.asin(Math.toDegrees(0.5)) C. Math.sin(Math.toRadians(0.5)) D. Math.sin(0.5)

B

To obtain the sine of 35 degrees, use _______. A. Math.sin(35) B. Math.sin(Math.toRadians(35)) C. Math.sin(Math.toDegrees(35)) D. Math.sin(Math.toRadian(35)) E. Math.sin(Math.toDegree(35))

The ____ contains the .NET components that you can use to develop the graphical user interface for a program.

Toolbox

The ____ method of the String class is used to remove spaces from the string.

Trim

A Double variable can be used in arithmetic operations.

True

A Function procedure declaration must define what type of data it will return when it is called.

True

A computer program can perform addition, subtraction, multiplication, and division operations on numeric data.

True

A green squiggly underline beneath a variable name in a declaration statement indicates that the variable is unused in the program.

True

A local variable is a variable that can only be accessed in the region in which it was defined.

True

A programming language is a set of words and symbols that can be interpreted by special computer software to create instructions that can be executed by a computer.

True

A splash screen like the one in the accompanying figure can be used to make a program appear to load faster than it actually does.

True

Almost all of the objects available in the .NET framework, such as buttons, text boxes, and picture boxes, are available in ASP.NET 3.5.

True

An InputBox object allows user input without the need for a TextBox object on the Windows Form object.

True

An access specifier determines the availability of a variable to other parts of the application.

True

An event planning document details each object in the user interface that will trigger an event and what actions will be taken when that event occurs.

True

By default, each validation control displays an error message next to the object it validates.

True

Good coding practice dictates that elements within a statement should be separated by a space to make the statement easier to read, even though the space is not required.

True

If an exception occurs in the Try section of a Try-Catch structure and there is no matching Catch block, the program will stop.

True

If the developer writes no code for a class constructor, Visual Basic automatically generates whatever processing must be accomplished to prepare the object for use.

True

In an If...Then...Else statement, if the condition is false, the statements between the Else and End If keywords will be executed.

True

In the case of an infinite while loop, the while expression (that is, the loop condition) is always true.

True

It is best to indent the body of the loop, to identify clearly the code that is being repeated.

True

Modeless forms are used more often than modal forms in Windows applications.

True

Multiple radio buttons can be selected if the selected radio buttons are each in different container objects.

True

Passing a variable to an argument that is declared with the keyword ByRef in a procedure declaration allows the procedure to modify the value of the variable that is being passed.

True

Rapid application design tools are used to design the user interface quickly.

True

Smart actions can be specified for a menu by using Action Tags.

True

The * symbol in a SQL Select statement is used to select all fields within the table.

True

The .NET Framework 3.5 contains thousands of classes and many class libraries that can be used by Visual Basic developers.

True

The HTML code for an active server page includes the HTML to format and display the page, and might include JavaScript code to perform certain processing, such as ensuring that a text box contains data.

True

The Hide procedure of a Form object removes the form from view.

True

The MessageBox object appears on a separate screen in a Smartphone environment.

True

The ReDim statement can be used to change the size of an array.

True

The contents of the Properties window can be sorted alphabetically by property name.

True

The developer should not begin to write code until after the events and tasks within the events have been identified.

True

The feature in the accompanying figure displays all available options that will make the statement correct after a dot operator, an equal sign, or another special character required for the statement is entered in the code editor.

True

The installation files created by the ClickOnce Publishing wizard can be used for a software release.

True

The output of the following Java code is: Stoor. int count = 5; System.out.print("Sto"); do { System.out.print('o'); count--; } while (count >= 5); System.out.println('r');

True

The presentation tier of the three-tier structure consists of one or more forms and the objects placed on the forms.

True

The prompt message displayed in an InputBox object can be customized by the programmer.

True

The property value specified in an assignment statement must be a valid value for the property identified on the left side of the equal sign.

True

The purpose of the Common Language Runtime (CLR) is to translate Microsoft Intermediate Language (MSIL) into machine-executable instructions.

True

The while loop and the do loop are equivalent in their expressive power; in other words, you can rewrite a while loop using a do loop, and vice versa.

True

The word, Me, followed by a period will activate the IntelliSense feature.

True

To call a procedure in another object, a statement in the calling object must identify both the object and the procedure within the object.

True

To create a dynamic Web site using Visual Basic, the ASP.NET Web Site template should be selected.

True

To develop an application for a Pocket PC device, you should select the Smart Device application template when creating the project in Visual Basic.

True

To force a literal value to be treated as a specific data type, you must use a literal-type character designator.

True

To hold a TextBox object or a Button object, containers called div elements are placed on the Web page.

True

Visual Studio 2008 does not provide a way to print form images.

True

Visual Studio 2008 is an integrated development environment.

True

When a form is displayed as modal, no other forms in the application can be accessed by the user until the form is closed.

True

When a form is loaded as modeless, other forms in the application can be accessed by the user.

True

When a procedure call is completed, the program returns to the calling procedure and continues execution as normal.

True

When entering data on a Smartphone, the first letter of a sentence is automatically capitalized.

True

When expecting a number from an input box, the IsNumeric function should be used to ensure that the input data can be converted to a numeric variable.

True

When nesting loops, the inner loop must be completely contained in the outer loop and must use a different control variable.

True

When setting up a mask for a MaskedTextBox object, select the Use Validating Type check box to cause the object to verify that the user entered valid numeric data.

True

When you pass a variable as an argument that was declared with the ByVal keyword in a procedure, that procedure cannot change the original value of the variable.

True

When you save a Visual Basic project the first time, you must select the location where the project is to be saved.

True

You cannot use the same name for two different GUI objects on a Windows Form object.

True

You must instantiate an object based on a class in order for the processing in the object to take place.

True

When adding a Web reference to an application, the information about the Web service is displayed after the Web service ____ has been entered.

URL

D

What is Math.rint(3.5)? A. 3.0 B. 3 C. 4 D. 4.0 E. 5.0

C

What is Math.round(3.6)? A. 3.0 B. 3 C. 4 D. 4.0

a[0][0]

What is the index variable for the element at the first row and first column in array a?

A

What is the output of System.out.println('z' - 'a')? A. 25 B. 26 C. a D. z

4 4 11 15

What is the output of the following code? public class Test { public static void main(String[] args) { int[][] matrix = {{1, 2, 3, 4, 5}, {4, 5, 6, 4, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}}; for (int i = 0; i < matrix.length; i++) System.out.print(matrix[i][3] + " "); } }

2 5 9 13

What is the output of the following code? public class Test { public static void main(String[] args) { int[][] matrix = {{1, 2, 3, 4}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}}; for (int i = 0; i < 4; i++) System.out.print(matrix[i][1] + " "); } }

4 5 6 7

What is the output of the following code? public class Test5 { public static void main(String[] args) { int[][] matrix = {{1, 2, 3, 4}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}}; for (int i = 0; i < 4; i++) System.out.print(matrix[1][i] + " "); } }

5 33

What is the printout of the following program? public class Test { public static void main(String[] args) { int[][] values = {{3, 4, 5, 1}, {33, 6, 1, 2}}; for (int row = 0; row < values.length; row++) { System.out.print(m(values[row]) + " "); } } public static int m(int[] list) { int v = list[0]; for (int i = 1; i < list.length; i++) if (v < list[i]) v = list[i]; return v; } }

1

What is the printout of the following program? public class Test { public static void main(String[] args) { int[][] values = {{3, 4, 5, 1}, {33, 6, 1, 2}}; int v = values[0][0]; for (int[] list : values) for (int element : list) if (v > element) v = element; System.out.print(v); } }

B

What is the return value of "SELECT".substring(0, 5)? A. "SELECT" B. "SELEC" C. "SELE" D. "ELECT"

A

What is the return value of "SELECT".substring(4, 4)? A. an empty string B. C C. T D. E

True

When you create an array using the following statement, the element values are automatically initialized to 0. int[][] matrix = new int[5][5]; (T/F)

ABCE

Which of the following are valid specifiers for the printf statement? A. %4c B. %10b C. %6d D. %8.2d E. %10.2e

AB

Which of the following assignment statements is correct? A. char c = 'd'; B. char c = 100; C. char c = "d"; D. char c = "100";

D

Which of the following is the correct expression of character 4? A. 4 B. "4" C. '\0004' D. '4'

C

Which of the following is the correct statement to return JAVA? A. toUpperCase("Java") B. "Java".toUpperCase("Java") C. "Java".toUpperCase() D. String.toUpperCase("Java")

char[][] charArray = {{'a', 'b'}, {'c', 'd'}};

Which of the following statements are correct?

When creating a program in Visual Studio, the ____ is the window that you use to build the program and which will display on your screen when the program is executed.

Windows Form object

Which of the following should be defined as a void method?

Write a method that prints integers from 1 to 100.

What is y after the following for loop statement is executed? int y = 0; for (int i = 0; i < 10; ++i) { y += 1; }

Y is 10.

The ____ operator is used for exponentiation.

^

CDE

____________________ returns true. A. "peter".compareToIgnoreCase("Peter") B. "peter".compareToIgnoreCase("peter") C. "peter".equalsIgnoreCase("Peter") D. "peter".equalsIgnoreCase("peter") E. "peter".equals("peter")

A variable that is declared inside a method is called ________ variable.

a local

All of the following methods are implicitly final except a method in an abstract class. a private method a method declared in a final class. static method

a method in an abstract class.

Each time a method is invoked, the system stores parameters and local variables in an area of memory, known as ________, which stores elements in last-in first-out fashion.

a stack

________ is a simple but incomplete version of a method.

a stub

Assume double[][][]x = new double[4][5][6], what are x.length, x[2].length,and x[0][0].length?

a. 4, 5, and 6

What happens when this is used in a constructor's body to call another constructor of the same class if that call is not the first statement in the constructor? a. A compilation error occurs. b. A runtime error occurs. c. A logic error occurs. d. Nothing happens. The program compiles and runs.

a. A compilation error occurs

Which statement is false? a. The compiler always creates a default constructor for a class. b. If a class's constructors all require arguments and a program attempts to call a no-argument constructor to initialize an object of the class, a compilation error occurs. c. A constructor can be called with no arguments only if the class does not have any constructors or if the class has a public no-argument constructor. d. None of the above.

a. The compiler always creates a default constructor for the class.

Which of the following should be defined as a void method?

a. Write a method that prints from 1 to 100

Blank is a construct that defines objects of the same type.

a. a class

Blank is invoked to create an object

a. a constructor

Suppose the xMethod() is invoked from a main method in a class as follows xMethod() is blank in the class. public static void main(String[]args){ xMethod(): }

a. a static method

Blank is a simple but incomplete version of a method

a. a stub

What is the index variable for the element at the first row and first column in array a?

a. a[0][0]

What is the representation of the third element in an array called a?

a. a[2]

(char)('a'+Math.random()*('z' -'a' +1)) returns a random character

a. between 'a' and 'z'

Which code fragment would correctly identify the number of arguments passed via the command line to a java application excluding the name of the class that is being invoked

a. int count = args.length;

What is list1 after executing the following statements? int[]list 1 = {1,2,3,4,5,6}; int[] list2 = reverse(list1);

a. list1 is 1 2 3 4 5 6

Which of the following statements is true? a. Methods and instance variables can both be either public or private. b. Information hiding is achieved by restricting access to class members via keyword public. c. The private members of a class are directly accessible to the clients of a class. d. None of the above is true.

a. methods and instance variables can both be either public or private.

Which of the following can be placed in the blank line in the following code? public class Test{ private int id; public void m1(){ ___________.id = 45; } }

a. this

When you create an array using the following statement, the element values are automatically initialized to 0 int[][]matrix = new int[5][5];

a. true

Which method returns an array of the enum's constants? a. values. b. getValues. c. constants. d. getConstants.

a. values

Suppose your method does not return any value, which of the following keywords can be used as a return type?

a. void

What is the index variable for the element at the first row and first column in array a?

a[0][0]

What is the representation of the third element in an array called a?

a[2]

A(n) ___ class cannot be instantiated.

abstract

The ASP.NET 3.5 technology used with Visual Basic 2008 creates a(n) ____.

active server page

what order should you use To add 0.01 + 0.02 + ... + 1.00, the numbers to get better accuracy?

add 0.01, 0.02, ..., 1.00 in this order to a sum variable whose initial value is 0.

An array can be used in which of the following ways?

all of these

A variable or a value listed in a call to a method is called

an argument

Static class variables:

are shared by all objects of a class

How can you get the word "abc" in the main method from the following call? java Test "+" 3 "abc" 2

args[2]

Addition and subtraction are considered to be ____ operations performed by a computer.

arithmetic

A(n) ____ variable is a variable that can store more than one value.

array

Assume int[][] x = {{1,2}, {3,4,5}, {5,6,5,9}} what are x.[0]length, x[1].length, and x[2].length?

b. 2, 3, 4

If you declare an array double[]list = {3.4, 2.0, 3.5, 5.5} list[1] is

b. 2.0

Assume double[][]x = new double[4][5] what are x.length and x[2].length?

b. 4 and 5

How many elements are in array double[] list= new double[5]?

b. 5

Which of the following statements is correct

b. A reference variable references to an object c. a data field in a class must be of primitive type

Which correctly create an array of fine empty Strings?

b. String[]a = { " ", " ", " ", " ", " "};

Blank is to implement one method in the structure chart at a time from the top to the bottom

b. Top-Down Approach

Assume int[] scores = {1, 20, 30, 40, 50} what is the output of System.out.println (java.util.Arrays.toString(Scores))?

b. [1,20,30,40,50]

A programmer-defined constructor that has no arguments is called a(n) ________. a. empty constructor. b. no-argument constructor. c. default constructor. d. null constructor.

b. a no-argument constructor

Blank represents an entity in the real world that can be distinctly identified

b. an object

(int)('a' + Math.random()*('z'-'a'+1)) returns a random number

b. between (int)'a' and (int)'z'

An object is an instance of a blank

b. class

Assume java.util.Date[] dates = new.java.util.Date[10], which of the following statements are true?

b. dates[0] is null c. dates =new.java.util.Date[5] is fine, which assigns a new array to dates

The default value for data field of a boolean type , numeric type, object type is

b. false, 0, null

The static method ________ of class String returns a formatted String. a. printf. b. format. c. formatString. d. toFormatedString.

b. format

Composition is sometimes referred to as a(n) ________. a. is-a relationship b. has-a relationship c. many-to-one relationship d. one-to-many relationship

b. has-a relationship

The JVM stores the array in an area of memory, called blank, which is used for dynamic memory allocation where blocks of memory are allocated and freed in an arbitrary order.

b. heap

Which syntax imports all static members of class Math? a. import java.lang.Math.*. b. import static java.lang.Math.*. c. import static java.lang.Math. d. None of the above.

b. import static java.lang.Math.*

What is the list1 after executing the following statement? double [] list1 = {3.1 ,3.1, 2.5, 6.4}; sectionSort(list1);

b. list1 is 2.5 3.1 3.1 6.4

What is list1 after executing the following statements? int[]list 1 = {1,2,3,4,5,6}; list 1 = reverse(list1);

b. list1 is 6 5 4 3 2 1

The signature of a method consists of

b. method name and parameter list

Arguments to methods always appear within

b. parentheses

When you invoke a method with a parameter, the value of the argument s passed to the parameter

b. pass by value

When implementing a method, use the class's set and get methods to access the class's ________ data. a. public. b. private. c. protected. d. All of the above.

b. private

Does the method call cause compile errors? public static void main(String[]args){ Math.pow(2,4); }

b.No

A subclass inherits attributes from a(n) ____ class.

base

Assigning a subclass reference to a superclass variable is safe ________.

because the subclass object is an object of its superclass.

(char)('a' + Math.random() * ('z' - 'a' + 1)) returns a random character ________.

between 'a' and 'z'

(int)('a' + Math.random() * ('z' - 'a' + 1)) returns a random number ________.

between (int)'a' and (int)'z'

(int)(Math.random() * (65535 + 1)) returns a random number

between 0 and 65535

Data ____ allows you to display each field in a database table as an object on a Windows form.

binding

Data ____ is the term that is used to refer to loading the DataSet string.

binding

A prefix of ____ is used to denote that a variable has been defined as a Boolean data type.

bln

A(n) ____-controlled loop tests the condition after the code in the loop body has been executed.

bottom

In a three-tier architecture, the classes in the ____ tier use data entered by users and data obtained from storage to perform the logic and calculations.

business

The ____ tier implements the "business rules" required for the application.

business

Which of the following is the best for generating random integer 0 or 1

c. (int)(Math.random()+0.5)

If a key is not in the list the binarySearch method returns

c. -(insertion point + 1)

public class Test{ public static void main(String[]args){ for(int i = 0; i <args.length; i++){ System.out.print(args[i] + " "); What is the output if you run the program using java Test 1 2 3

c. 1 2 3

How many elements are array matrix (int[][] matrix = new int[5][5])

c. 25

Assume int[][] x = {{1,2}, {3,4}, {5,6}} what are x.length and x[0].length

c. 3 and 2

Assume int[]t={1,2,3,4} What is .length?

c. 4

BigDecimal gives you control over how values are rounded. By default: a. all calculations are approximate and no rounding occurs. b. all calculations are approximate and rounding occurs. c. all calculations are exact and no rounding occurs. d. all calculations are exact and rounding occurs.

c. All calculations are exact and no rounding occurs.

Instance variables declared final do not or cannot: a. Cause syntax errors if used as a left-hand value. b. Be initialized. c. Be modified after they are initialized. d. None of the above.

c. Be modified after they are initialized.

Suppose TestSimpleCircle and SimpleCircle in Listin 9.1 are in two separate files named TSC.java and SC.java. What is the outcome of compiling TSC.java the SC.java?

c. Both compile fine.

When no access modifier is specified for a method or variable, the method or variable: a. Is public. b. Is private. c. Has package access. d. Is static.

c. Has package access.

Which of the following is false? a. Method finalize does not take parameters and has return type void. b. Memory leaks using Java are rare because of automatic garbage collection. c. Objects are marked for garbage collection by method finalize. d. The garbage collector reclaims unused memory.

c. Objects are marked for garbage collection by method finalize.

The _________ of a class are also called the public services or the public interface that the class provides to its clients. a. public constructors. b. public instance variables. c. public methods. d. All of the above.

c. Public methods

A constructor cannot: a. be overloaded. b. initialize variables to their defaults. c. specify return types or return values. d. have the same name as the class.

c. Specify return types or return values.

Analyze the following code int[]list=new int[5]; list = new int[6];

c. The code can compile and run fine. The second line assigns a new array to list.

Which of the following class members should usually be private? a. Methods. b. Constructors. c. Variables (or fields). d. All of the above.

c. Variables (or fields)

Each time a method is invoked the system stores parameters and local variables in an area of memory known as blank, which stores elements in last-in first-out fashion

c. a stack

Suppose the xMethod() is invoked in the following constructor in a class, xMethod() is blank in the class. public MyClass(){ xMethod(): }

c. a static method or an instance method

Which statement is false? a. An enum declaration is a comma-separated list of enum constants and may optionally include other components of traditional classes, such as constructors, fields and methods. b. Any attempt to create an object of an enum type with operator new results in a compilation error. c. An enum constructor cannot be overloaded. d. enum constants are implicitly final and static.

c. an enum constructor cannot be overloaded.

A method that is associated with an individual object is called

c. an instance method

How can you get "abc" in the main method for the following call? java Test "+" 3 "abc" 2

c. args[2]

(int)(Math.random()*(65535+1)) returns a random number

c. between 0 and 65535

The keyword blank is required to declare a class

c. class

Which statement is false? a. The actual data representation used within the class is of no concern to the class's clients. b. Clients generally care about what the class does but not how the class does it. c. Clients are usually involved in a class's implementation. d. Hiding the implementation reduces the possibility that clients will become dependent on class-implementation details.

c. client's are usually involved in a class' implementation.

What is the correct term for numbers[99]?

c. indexed variable

What is the advantage of encapsulation?

c. it changes the implementation without changing a class's contract and causes no consequential changes to other code

The blank method sorts the array scores of the double[] type

c. java.util.Arrays.sort(Scores)

Set methods are also commonly called ________ methods and get methods are also commonly called ________ methods. a. query, mutator. b. accessor, mutator. c. mutator, accessor. d. query, accessor.

c. mutator, accessor

Suppose you wish to provide an access method for a boolean property finished what signature of the method should be

c. public boolean isFinished()

All java applications must have a method

c. public static void main(String[]args)

When you pass an array to a method the method receives

c. the reference of the array

When you return an array from a method the method returns

c. the reference of the array

When invoking a method with an object argument , blank is passed

c. the reference of the object

To prevent a class from being instantiated

c. use the private modifier on the constructor

Given the declaration Circle x = new Circle(), which of the following statement is most accurate

c. x contains a reference to a Circle object

Given the declaration Circle[]x = new Circle[10], which of the following statement is most accurate?

c. x contains a reference to an array and each element in the array can hold a reference to a Circle object

To execute code in a procedure, a procedure ____ must be made.

call

The ____ prefix is used when naming a ComboBox object like the one in the accompanying figure.

cbo

public class Exam1 { public static void main(String[] args) { System.out.print("The grade is " +getGrade(78.5)); System.out.print("\nThe grade is " +getGrade(59.5)); } public static ____ getGrade (double score){ if(score>=90.0) return 'A'; else if (score>=80.0) return 'B'; else if (score >= 70.0) return 'C'; else if (score>=60.0) return 'D'; else return 'F'; } }

char

Which of the following are valid array declarations?

char[] charArray = new char[26];

Which of the following statements are correct?

char[][] charArray = {{'a', 'b'}, {'c', 'd'}};

Which of the following statements are correct?

char[][] charArray = {{'a','b'}, {'c','d'}};

_________ declares an array of char.

char[]char

All exception classes inherit, either directly or indirectly, from ________.

class Throwable.

A(n) ____ operator allows you to perform arithmetic operations with a variable and store the results back to that variable.

compound

When more than one condition is included in an If...Then...Else statement, the conditions are called ____ conditions.

compound

The ampersand (&) symbol is the operator used to ____ two strings together.

concatenate

The process of joining two string values together is called ____.

concatenation

A statement that tests a value is called a ____ statement.

conditional

The first step in accessing database information is to establish a ____ with the database.

connection

Java requires a ________ call for every object that's created.

constructor

The ____ prepares an object for use in the program.

constructor

The Panel, GroupBox, and TabControl objects are examples of ____ objects.

container

The ____ follows the keyword For in a For...Next loop.

control variable

A(n) ____ variable keeps track of how many times a loop has executed.

counter

A loop that repeats a specific number of times is known as a _____.

counter-controlled loop

Assume int[] scores = {1, 20, 30, 40, 50} what value does java.util.Arrays.binarySearch(scores,30) return?

d. 2

If you declare an array double[]list = {3.4, 2.0, 3.5, 5.5} the highest index in array list is

d. 3

Which of the following is false? a. A static method must be used to access private static instance variables. b. A static method has no this reference. c. A static method can be accessed even when no objects of its class have been instantiated. d. A static method can call instance methods directly.

d. A static method can call instance methods directly

Having a this reference allows: a. a method to refer explicitly to the instance variables and other methods of the object on which the method was called. b. a method to refer implicitly to the instance variables and other methods of the object on which the method was called. c. an object to reference itself. d. All of the above.

d. All of the above

Constructors: a. Initialize instance variables. b. When overloaded, can have identical argument lists. c. When overloaded, are selected by number, types and order of types of parameters. d. Both (a) and (c).

d. Both a and c

Static class variables: a. are final. b. are public. c. are private. d. are shared by all objects of a class.

d. Shared by all objects of a class.

The blank method copies the sourceArray to the targetArray

d. System.arraycopy (sourceArray, 0, targetArray, 0, sourceArray.length);

Which of the following statements is false? a. An application that requires precise floating-point calculations such as those in financial applications should use class BigDecimal from package java.math. b. We use class NumberFormat for formatting numeric values as locale-specific strings. c. In the U.S, locale, the value 15467.82 would be formatted as "15,467.82", whereas in many European locales it would be formatted as "15.467,56". d. The BigDecimal method format receives a double argument and returns a BigDecimal object that represents the exact value specied.

d. The BigDecimal method format receives a double argument and returns a BigDecimal object that represents the exact value specified.

Which of the following statements is false? a. If a program uses multiple classes from the same package, these classes can access each other's package access members directly through references to objects of the appropriate classes, or in the case of static members, through the class name. b. Package access is rarely used. c. Classes in the same source file are part of the same package. d. Use the access modifier package to give a method or variable package access.

d. Use the access modifier package to give a method or variable package access

A variable defined inside a method is referred to as

d. a local variable

When must a program explicitly use the this reference? a. Accessing a private variable. b. Accessing a public variable. c. Accessing a local variable. d. Accessing an instance variable that is shadowed by a local variable

d. accessing an instance variable that is shadowed by a local variable.

Using public set methods helps provide data integrity if: a. The instance variables are public. b. The instance variables are private. c. The methods perform validity checking. d. Both b and c.

d. both b and c

Variables that are shared by every instances of a class are

d. class variables

8.11 Q2: Which of the following is false? a. a. A static method must be used to access private static instance variables. b. b. A static method has no this reference. c. c. A static method can be accessed even when no objects of its class have been instantiated. d. d. A static method can call instance methods directly.

d. d. A static method can call instance methods directly.

You can declare two variables with the same name in

d. different methods in a class

For the binarySearch method in section 7.10.2 what is the low and high after the first iteration of the while loop when invoking binarySearch(new int[] {1,4,6,8,10,15,20}, 11)?

d. low is 5 high is 4

Suppose the method p has the following heading: public static int[]p() What return statement may be used in p()?

d. return new int[]{1,2,3};

A final field should also be declared ________ if it is initialized in its declaration. a. private. b. public. c. protected. d. static.

d. static

A ____ is a collection of data organized in a manner that allows access, retrieval, and use of that data.

database

A prefix of ____ is used to denote a variable defined as a Decimal data type.

dec

Which of the following is not a control structure: sequence structure selection structure declaration structure repetition structure

declaration structure

You should ____ as the second phase in the program development life cycle, after the program requirements have been gathered and analyzed.

design the user interface

Which of the loop statements always have their body executed at least once?

do-while loop

for ( ; false; ) System.out.println("Welcome to Java")

does not print anything

what is the correct loop that correctly computes 1/2 + 2/3 + 3/4 + ... + 99/100?

double sum = 0; for (int i = 1; i <= 99; i++) { sum += 1.0 * i / (i + 1); } or double sum = 0; for (int i = 1; i <= 99; i++) { sum += i / (i + 1.0);

Assume int[] scores = {1, 20, 30, 40, 50} what value does java.util.Arrays.binarySearch(scores,3) return?

e. -2

Assume list is {3.1, 3.1, 2.5, 6.4, 2.1} what is the content of the list after the first iteration of the outer loop in the method

e. 2.1 3.1 2.5 6.4 3.1

To declare a constant MAX_LENGTH as a member of the class you write

e. final static double MAX_LENGTH = 99.98;

Suppose a method p has the following heading: public static int[][]p() What return statement may be used in p()?

e. return new int[][]{{1,2,3}, {2,4,5}};

Clicking a button like the one labeled Reset Window in the accompanying figure when a Visual Basic program is running triggers a(n) ____.

event

A(n) ____ document consists of a table that specifies an object in the user interface that will cause an event, the action taken by the user to trigger the event, and the event processing that must occur.

event planning

Most Visual Basic 2008 programs are ____ programs because they communicate with the user through a graphical user interface (GUI).

event-driven

A(n) ________ indicates a problem that occurs while a program executes.

exception

A method can be defined inside a method in Java.

false

A variable declared in the for loop control can be used after the loop exits.

false

Binary search can be applied on an unsorted list.

false

Each Java class must contain a main method.

false

The element in the array must be of a primitive data type.

false

The name length is a method in an array.

false

The signature of a method consists of the method name, parameter list and return type.

false

You can use the operator == to check whether two variables refer to the same array.

false

A ____ contains a specific piece of data within a record in a database table.

field

Any field declared with keyword ________ is constant.

final

When the user interacts with an object in the graphical user interface, the ____ shifts to that object.

focus

Which of the following loops prints "Welcome to Java" 10 times?

for (int count = 1; count <= 10; count++) { System.out.println("Welcome to Java"); } or for (int count = 0; count < 10; count++) { System.out.println("Welcome to Java"); }

This type of loop is ideal in situations where the exact number of iterations is known.

for loop

Which prefix should be used to name a Windows Form object?

frm

You are designing a form that will be used to record the mileage driven by a sales representative. Which of the following is the best name for this form?

frmMilesDriven

You should ____ as the first phase of the program development life cycle.

gather and analyze the program requirements

The ____ is comprised of the program's window and the objects in the window.

graphical user interface (GUI)

Comments are displayed (by default) with ____.

green text

The ____ industry is the largest user of PDAs.

health care

The JVM stores the array in an area of memory, called ________, which is used for dynamic memory allocation where blocks of memory are allocated and freed in an arbitrary order.

heap

A(n) ____ key is a keyboard shortcut for opening a menu.

hot

Suppose the input for number is 9. What is the output from running the following program? import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an integer: "); int number = input.nextInt(); int i; boolean isPrime = true; for (i = 2; i < number && isPrime; i++) { if (number % i == 0) { isPrime = false; } } System.out.println("i is " + i); if (isPrime) System.out.println(number + " is prime"); else System.out.println(number + " is not prime"); } }

i is 4 followed by 9 is not prime

int number = 25; int i; boolean isPrime = true; for(i = 2; i< number; i++){ if(number %i == 0){ isPrime = false; break; } } System.out.println("i is " +i+ " isPrime is " +isPrime);

i is 5 isPrime is false

What is the printout after the following loop terminates? int number = 25; int i; boolean isPrime = true; for (i = 2; i < number && isPrime; i++) { if (number % i == 0) { isPrime = false; } } System.out.println("i is " + i + " isPrime is " + isPrime);

i is 6 isPrime is false

int number = 25; int i; boolean isPrime = true; for(i=2; i<number && isPrime; i++){ if(number%i ==0){ isPrime = false; } } System.out.print(i); System.out.print(isPrime);

i is 6 isPrime is false

Suppose cond1 is a Boolean expressions. When will this while condition be true? while (cond1) ...

in case cond1 is true

What is the correct term for numbers[99]?

indexed variable

As demonstrated in the accompanying figure, a loop that does not terminate is called a(n) ____ loop.

infinite

To avoid duplicating code, use ________, rather than ________.

inheritance, the "copy-and-past" approach.

When an object requires data when it is instantiated, the data can be passed as part of the ____ code.

instantiation

The control variable of a counter-controlled loop should be declared as ________to prevent errors.

int

Which of the following is equivalent to this code segment? int total = 0; for (int i = 0; i <= 20; i += 2) total += i;

int total = 0; for (int i = 0; i <= 20; total += i, i += 2);

public class Exam1 { public static void main(String[] args) { System.out.println(xMethod(5,500L)); } public static int xMethod (int n, long l) { System.out.println("int, long"); return n; } public static long xMethod (long n, long l) { System.out.println("long,long"); return n; } }

int, long 5

The \ operator is the arithmetic operator for ____ division.

integer

If the superclass contains only abstract method declarations, the superclass is used for ________.

interface inheritance.

An uncaught exception ________.

is an exception that occurs for which there are no matching catch clauses.

The .class extension on a file means that the file:

is produced by the Java compiler

Inheritance is also known as the

is-a relationship.

A(n) ____ is a single repetition of a loop.

iteration

The command ___ executes a Java application.

java

Which command executes the Java class file Welcome.class?

java Welcome

The ________ method sorts the array scores of the double[] type.

java.util.Arrays.sort(scores)

When naming a Label object, the ____ prefix should be used.

lbl

The reverse method is defined in this section. What is list1 after executing the following statements? int[] list1 = {1, 2, 3, 4, 5, 6}; int[] list2 = reverse(list1);

list1 is 1 2 3 4 5 6

Use the selectionSort method presented in this section to answer this question. What is list1 after executing the following statements? double[] list1 = {3.1, 3.1, 2.5, 6.4}; selectionSort(list1);

list1 is 2.5 3.1, 3.1, 6.4

Variables defined inside a method are called ________.

local variables

A computer uses ____ operations to compare two values to see if they are equal to each other.

logical

To create a compound condition in an If statement, a(n) ____ operator is required.

logical

Which is an infinite loop?

loopCount = 1; while(loopCount < 3); { System.out.println("Hello"); }

For the binarySearch method in Section 7.10.2, what is low and high after the first iteration of the while loop when invoking binarySearch(new int[]{1, 4, 6, 8, 10, 15, 20}, 11)?

low is 0 and high is 6

You must call most methods other than ________ explicitly to tell them to perform their tasks.

main

The signature of a method consists of ________.

method name and parameter list

Java allows you to declare methods with the same name in a class. This is called ________.

method overloading

The ____ prefix is used for a MenuStrip object.

mnu

A ____ form retains the input focus while open so that the user cannot switch between Form objects until the first form is closed.

modal

What is the number of iterations in the following loop? for (int i = 1; i <= n; i++) //iteration

n

How many iterations will there be? for (int i = 1; i < n; i++) //iteration

n-1

What statement can be used to invoke the following method? public static int m(int[][]m)

new int[][]{{1, 2}, {3, 4}}

Does the method call in the following method cause compile errors? public static void main(String[] args) { Math.pow(2, 4); }

no

Does the return cause compile errors? int max = 0; if (max != 0) System.out.println(max); else return; }

no

Will this terminate? int balance = 10; while (true){ if (balance < 9) continue; balance = balance - 9;

no

Variables defined in the method header are called ________.

parameters

Arguments to methods always appear within ________.

parentheses

Open and close ____ immediately following the name of a procedure identify a Visual Basic statement as a procedure call statement.

parentheses

When you invoke a method with a parameter, the value of the argument is passed to the parameter. This is referred to as ________.

pass by value

A well-designed method ________.

performs a single, well-defined task

Data is said to be ____ if it remains available after the computer is powered off.

persistent

Data that is stored in a file or database on disk often is called ____ data because the data remains after the program is terminated.

persistent

The unit of measurement for a selected PictureBox object is ____.

pixels

In a three-tier architecture, the ____ tier contains the classes that display information and accept user input.

presentation

for( ; ; ) System.out.println("Welcome to Java");

prints out Welcome to Java forever

What is the output of the following code: for ( ; ; ) System.out.println("Welcome to Java");

prints out Welcome to Java forever.

Declaring instance variables ________ is known as data hiding or information hiding.

private

To create a new project using Visual Studio, you must specify both the type of application you will create and the ____ that you wish to use.

programming language

Each control has ____.

properties

33

public class Test { public static void main(String[] args) { int[][] values = {{3, 4, 5, 1}, {33, 6, 1, 2}}; int v = values[0][0]; for (int row = 0; row < values.length; row++) for (int column = 0; column < values[row].length; column++) if (v < values[row][column]) v = values[row][column]; System.out.print(v); } }

All Java applications must have a method ________.

public static void main(String[] args)

A(n) ____ document identifies the purpose of the program being developed, the application title, the procedures to be followed when using the program, any equations and calculations required, any conditions within the program that must be tested, and any notes and restrictions that must be followed by the program.

requirements

Suppose a method p has the following heading: public static int[][] p() What return statement may be used in p()?

return new int[][]{{1, 2, 3}, {2, 4, 5}};

Suppose a method p has the following heading: public static int[] p() What return statement may be used in p()?

return new int[]{1, 2, 3};

The prefix ____ is used when naming a RegularExpressionValidator object on a Web form.

rev

The prefix ____ is used when naming a RequiredFieldValidator object on a Web form.

rfv

A ____ search of an array starts at the beginning of the array and inspects each element until a match is found.

sequential

A simple text file is called a ____ file.

sequential

The ____-side computer is the computer that will deliver the Web page to the user's computer.

server

A blue line, called a(n) ____ line, that appears when you are dragging a GUI object on a Windows Form object indicates that the outer edge of the object being dragged is aligned with the object connected by the blue line.

snap

A variable that has been defined as a Single data type is denoted with the ____ prefix.

sng

The throws clause of a method:

specifies the exceptions a method throws.

A constructor cannot:

specify return types or return values..

A class that inherits attributes from another class is called a(n) ____.

subclass

Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?

super

A set of rules that specify how each code statement must be written is called the ____ of the programming language.

syntax

A ____ in a database structures data into rows and columns.

table

Which of the loop statements always have their body executed at least once.

the for loop

Reference-type variables (called references) store ________ in memory.

the location of an object

What is the value of balance? int balance = 10; while(balance>=1){ if(balance<9)continue; balance = balance -9; } System.out.println(balance);

the loop does not end

The BinarySearch procedure returns ____ if the desired value is found in the array.

the matching index value

public class Exam1 { public static void main(String[] args) { System.out.println(xMethod((double)5)); } public static int xMethod (int n) { System.out.println("int"); return n; } public static long xMethod (long n) { System.out.println("long"); return n; } }

the program does not compile

When you return an array from a method, the method return

the reference of the array

An exception object's ________ method returns the exception's error message.

toString

The ____ of Visual Studio 2008 contains buttons for commands that are frequently used, such as Open New Project, Save, Cut, Copy, Paste, and Undo.

toolbar

A call for the method with a void return type is always a statement itself, but a call for the method with a non-void return type can be treated as either a statement or an expression.

true

A continue statement can be used only in a loop.

true

A continue statement can only be used in a loop.

true

A method can be declared with no parameters.

true

An array variable can be declared and redeclared in the same block.

true

If a method does not contain any parameters, you must invoke it with a pair of empty parentheses.

true

In a for statement, if the continuation condition is blank, the condition is assumed to be

true

In a for statement, if the continuation condition is blank, the condition is assumed to be ______.

true

Methods can be declared in any order in a class.

true

The actual parameters of a method must match the formal parameters in type, order, and number.

true

The arguments passed to the main method is an array of strings. If no argument is passed, args.length is 0.

true

The array index of the first element in an array is 0.

true

The arraycopy method does not allocate memory space for the target array. The target array must already be created with memory space allocated.

true

The elements inside the for loop control are separated using semicolons instead of commas.

true

The modifiers and return value type do not contribute toward distinguishing one method from another, only the parameter list.

true

The while loop and the do loop are equivalent in their expressive power; in other words, you can rewrite a while loop using a do loop, and vice versa.

true

When you create an array using the following statement, the element values are automatically initialized to 0. int[][]matrix = new int[5][5];

true

You can always convert a for loop to a while loop.

true

You can always convert a while loop to a for loop.

true

You can always write a program without using break or continue in a loop.

true

You may have a return statement in a void method.

true

You must have a return statement in a non-void method.

true

x.length does not exist if x is null.

true

you can always convert a while loop to a for loop.

true

The prefix ____ should be used for naming a TextBox object.

txt

Each class you create becomes a new ________ that can be used to declare variables and create objects.

type

What is i after the following for loop? int y = 0; for(int i = 0; i&lt;10;++i) { y+=i; }

undefined

Which method returns an array of the enum's constants?

values

A ________ method does not return a value.

void

Suppose your method does not return any value, which of the following keywords can be used as a return type?

void

public class Exam1 { public static void main(String[] args) { System.out.print("The grade is "); printGrade(78.5); System.out.print("The grade is "); printGrade(59.5); } public static ---- printGrade (double score) { if(score>=90.0){ System.out.println('A'); } else if (score>=80.0){ System.out.println('B'); } else if (score >= 70.0){ System.out.println('C'); } else if (score >= 60.0){ System.out.println('D'); } else{ System.out.println('F'); } } }

void

A return statement without any value can be used in ________.

void method

The default equals implementation of class Object determines:

whether two references refer to the same object in memory.

Declaring main as static allows the JVM to invoke main ________.

without creating an instance of the class in which main is declared.

The center portion of the Visual Studio window, called the ____, contains the form that will become the user interface.

work area

Assume x is 0. What is the output of the following statement? if (x>0) printf("x is greater than 0"); else if (x<0) printf("x is less than 0"); else printf("x equals zero")

x equals 0

assume x is 0 what what is the output of the following statements: if (x>0) print("x is greater then x"); else if (x<0) print ("x is less than 0"); else print ("x equals o");

x equals 0

Assume the signature of the method xMethod is as follows. public static void xMethod(double[] a) Which of the following could be used to invoke xMethod?

xMethod(new double[2]);

boolean[][]x=new boolean [3][]; x[0] = new boolean[1]; x[1] = new boolean [2]; x[2] = new boolean [3]; System.out.println("x[2][2] is " + x[2][2]);

x[2][2] is false

Assume boolean[][] x = new boolean[5][7], what is the index variable for the element at the last row and last column in array x?

x[4][6]

Do the following programs produce the same result? Program 1: public static void main(String[]args) { int[]list={1,2,3,4,5}; reverse(list); for(int i=0; i<list.length;i++) System.out.print(list[i] + " "); } public static void reverse(int[]list) { int[]newList = new int[list.length]; for (int i=0; i<list.length;i++) newList[i]=list[list.length-1-i]; list=newList; } Program 2: public static void main(String[]args) { int[]oldList={1,2,3,4,5}; reverse(oldList); for(int i=0; i<oldList.length;i++) System.out.print(oldList[i] + " "); } public static void reverse(int[]list) { int[]newList = new int[list.length]; for (int i=0; i<list.length;i++) newList[i]=list[list.length-1-i]; list=newList; }

yes

Do the following two statements in (I) and (II) result in the same value in sum? (I): for (int i = 0; i<10; ++i) { sum += i; } (II): for (int i = 0; i<10; i++) { sum += i; }

yes

Is the following loop correct? for (; ; );

yes

Will the following program terminate? int balance = 10; while (true) { if (balance < 9) break; balance = balance - 9; }

yes

Will this terminate? int balance = 10; while (true){ if (balance < 9) break; balance = balance - 9;

yes


Set pelajaran terkait

Nutrition Chapter 1 and Chapter 2 Quiz

View Set

Diversity Studies Chapter 4 & 5 & Knowledge Checks

View Set

Module 10 - The Employment Relationship

View Set

prepU ch 41 Management of Patients With Musculoskeletal Disorders

View Set

Anatomy Final: Aging, Senescence, and Death

View Set