question hot seat public myconstructor (int a, int b) { index = a+b; } a.parameters b.class name...

Post on 26-Dec-2015

221 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Question Hot Seat

public MyConstructor (int a, int b) {

index = a+b;}

A. ParametersB. Class NameC.BodyD.Modifier

Please put match these choices to these boxes from left to right

DBAC

Ask Audience50-50Call a friend

Which of the following is invalid identifier?

a. GoodVar b. $Good123Var

c. Good_123Var d. %Good$Var

100

200

300

500

1000

Ask Audience50-50Call a friend

How would you define a Java array?

a. GoodVar b. $Good123Var

a. Good_123Var a. %Good$Var

100

200

300

500

1000

Ask Audience50-50Call a friend

How would you define a Java array?

a. a collection of data values of different types

b. a collection of data values of the same type

c. a collection of characters that incidentally form a string

100

200

300

500

1000

d. a collection of primitive data types

Ask Audience50-50Call a friend

How would you define a Java array?

a. a collection of data values of different types

b. a collection of data values of the same type

c. a collection of characters that incidentally form a string

100

200

300

500

1000

d. a collection of primitive data types

Ask Audience50-50Call a friend

What are the two ways that a Java array can be declared?

a. <type>[ ] <arrayname>; <type> <arrayname>;

b. <type> <arrayname>[ ]; <type> <arrayname>;[ ]

c. [ ]<type> <arrayname>;<type>[ ] <arrayname>;

100

200

300

500

1000

d. <type>[ ] <arrayname>;<type> <arrayname>[ ];

Ask Audience50-50Call a friend

What are the two ways that a Java array can be declared?

a. <type>[ ] <arrayname>; <type> <arrayname>;

b. <type> <arrayname>[ ]; <type> <arrayname>;[ ]

c. [ ]<type> <arrayname>;<type>[ ] <arrayname>;

100

200

300

500

1000

d. <type>[ ] <arrayname>;<type> <arrayname>[ ];

Ask Audience50-50Call a friend

Which of the following declares an array of integers of size 20?

a. int[ ] a = int[20]; b. int[ ] a = new int[20];

c. int a = new int[19];

100

200

300

500

1000

d. int a[ ] = new int[19];

Ask Audience50-50Call a friend

Which of the following declares an array of integers of size 20?

a. int[ ] a = int[20]; b. int[ ] a = new int[20];

c. int a = new int[19];

100

200

300

500

1000

d. int a[ ] = new int[19];

Ask Audience50-50Call a friend

How would we access the 12th element of the array, x?

a. x(12); b. x(11);

c. x[12];

100

200

300

500

1000

d. x[11];

Ask Audience50-50Call a friend

How would we access the 12th element of the array, x?

a. x(12); b. x(11);

c. x[12];

100

200

300

500

1000

d. x[11];

Ask Audience50-50Call a friend

Why are loops particularly useful for array operations?

a. Because loops easily traverse through the indexes of the array.

b. Because loops solve problems that otherwise would not be solvable without them.

c. Because loops take less time to run than conventional coding without loops.

2000

4000

8000

16000

32000

d. Loops do not aid in the processing of arrays.

Ask Audience50-50Call a friend

Why are loops particularly useful for array operations?

a. Because loops easily traverse through the indexes of the array.

b. Because loops solve problems that otherwise would not be solvable without them.

c. Because loops take less time to run than conventional coding without loops.

2000

4000

8000

16000

32000

d. Loops do not aid in the processing of arrays.

Ask Audience50-50Call a friend

What does the following program do?

double x = 0, unknown;

for (int j = 0; j < someArray.length; j++){ x+=someArray[j];}unknown = x /someArray.length;

a. Computes the sum of the doubles in the array, someArray.

b. Deletes all the doubles in the array, someArray.

c. Computes the average of all the doubles in the array, someArray

2000

4000

8000

16000

32000

d. Computes the dot product of all the doubles in the array, someArray.

Ask Audience50-50Call a friend

What does the following program do?

double x = 0, unknown;

for (int j = 0; j < someArray.length; j++){ x+=someArray[j];}unknown = x /someArray.length;

a. Computes the sum of the doubles in the array, someArray.

b. Deletes all the doubles in the array, someArray.

c. Computes the average of all the doubles in the array, someArray

2000

4000

8000

16000

32000

d. Computes the dot product of all the doubles in the array, someArray.

Ask Audience50-50Call a friend

Given a value X, return the index of X in the array, if such X exists. Otherwise, return NOT_FOUND. We assume there are no duplicate entries in the array.

What are the two possible outcomes in this problem?

a. linear search and binary search

b. -1 and X

c. an index and a value

2000

4000

8000

16000

32000

d. successful and unsuccessful

Ask Audience50-50Call a friend

Given a value X, return the index of X in the array, if such X exists. Otherwise, return NOT_FOUND. We assume there are no duplicate entries in the array.

What are the two possible outcomes in this problem?

a. linear search and binary search

b. -1 and X

c. an index and a value

2000

4000

8000

16000

32000

d. successful and unsuccessful

Ask Audience50-50Call a friend

When would a programmer be forced to pick a linear search over a binary search?

a. When the items in the array are in ascending order

b. When the items in the array are in descending order

c. When the items in the array are unsorted

2000

4000

8000

16000

32000

d. Linear search is never a better choice than binary search.

Ask Audience50-50Call a friend

When would a programmer be forced to pick a linear search over a binary search?

a. When the items in the array are in ascending order

b. When the items in the array are in descending order

c. When the items in the array are unsorted

2000

4000

8000

16000

32000

d. Linear search is never a better choice than binary search.

Ask Audience50-50Call a friend

Which of the following best describes the protocol for a selection sort?

a. Identify the largest element.Place the element at the beginning of a target listRepeat

b. Identify the median of the listSplit the list into two halves, those smaller and those larger than the medianPerform the same sort on each of the smaller halves

c. Identify the smallest element of the listPlace the element in the beginning of the target list Repeat

2000

4000

8000

16000

32000

d. Identify the median element of the listPlace the element in the beginning of a target list Repeat

Ask Audience50-50Call a friend

Which of the following best describes the protocol for a selection sort?

a. Identify the largest element.Place the element at the beginning of a target listRepeat

b. Identify the median of the listSplit the list into two halves, those smaller and those larger than the medianPerform the same sort on each of the smaller halves

c. Identify the smallest element of the listPlace the element in the beginning of the target list Repeat

2000

4000

8000

16000

32000

d. Identify the median element of the listPlace the element in the beginning of a target list Repeat

Ask Audience50-50Call a friend

What is the biggest number of computations made for a binary search on a sorted array of size 64?

a) 3 b) 5

c) 6

2000

4000

8000

16000

32000

d) 8

Ask Audience50-50Call a friend

What is the biggest number of computations made for a binary search on a sorted array of size 64?

a) 3 b) 5

c) 6

2000

4000

8000

16000

32000

d) 8

Ask Audience50-50Call a friend

What is wrong with the following code?int product = 0, count=0;while (product < 2500){ product *= 5; count++;}

a. the syntax of the while statement is invalid

b. the operator, *=, does not exist.

c. it has an infinite loop

64000

125000

250000

500000

1000000

d. the count variable is initialized incorrectly.

Ask Audience50-50Call a friend

What is wrong with the following code?int product = 0, count=0;while (product < 2500){ product *= 5; count++;}

a. the syntax of the while statement is invalid

b. the operator, *=, does not exist.

c. it has an infinite loop

64000

125000

250000

500000

1000000

d. the count variable is initialized incorrectly.

Ask Audience50-50Call a friend

Assume you had a class BankInfo that contained three data members: accountNumber, pinNumber, and name. The data member name must be searchable by other classes.What access modifiers would you apply to these members?

a. make accountNumber private, pinNumber private, and name public

b. make accountNumber public, pinNumber private, and name public

c. make them all private

64000

125000

250000

500000

1000000

d. make them all public

Ask Audience50-50Call a friend

Assume you had a class BankInfo that contained three data members: accountNumber, pinNumber, and name. The data member name must be searchable by other classes.What access modifiers would you apply to these members?

a. make accountNumber private, pinNumber private, and name public

b. make accountNumber public, pinNumber private, and name public

c. make them all private

64000

125000

250000

500000

1000000

d. make them all public

Ask Audience50-50Call a friend

What is the difference in path name specification between the UNIX and Windows operating systems?

a. There are no .exe files in UNIX but there are .exe files in Windows

b. UNIX allows for spaces in file and directory names while Windows does not.

c. UNIX separates directories from subdirectories with forward slashes while Windows separates directories with backslashes.

64000

125000

250000

500000

1000000

d. There is no difference

Ask Audience50-50Call a friend

What is the difference in path name specification between the UNIX and Windows operating systems?

a. There are no .exe files in UNIX but there are .exe files in Windows

b. UNIX allows for spaces in file and directory names while Windows does not.

c. UNIX separates directories from subdirectories with forward slashes while Windows separates directories with backslashes.

64000

125000

250000

500000

1000000

d. There is no difference

Ask Audience50-50Call a friend

Assume you want to read the contents of a file and display to the monitor. Which file I/O classes can we use to accomplish this?

a. FileInputStream or FileOutputStream

b. FileInputStream or DataInputStream

c. FileOutputStream or DataOutputStream

64000

125000

250000

500000

1000000

d. DataInputStream or DataOutputStream

Ask Audience50-50Call a friend

Assume you want to read the contents of a file and display to the monitor. Which file I/O classes can we use to accomplish this?

a. FileInputStream or FileOutputStream

b. FileInputStream or DataInputStream

c. FileOutputStream or DataOutputStream

64000

125000

250000

500000

1000000

d. DataInputStream or DataOutputStream

Ask Audience50-50Call a friend

64000

125000

250000

500000

1000000

Ask Audience50-50Call a friend

64000

125000

250000

500000

1000000

top related