computer

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

What will be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 100; if (purchase > 1000) discountRate = 0.05; else if (purchase > 750) discountRate = 0.03; else if (purchase > 500) discountRate = 0.01;

0.0

How many times will the following do-while loop be executed? int x = 11; do { x += 20; } while (x > 100);

1

What is the output? System.out.printf("%.1f%%", 12.78);

12.8%

What will be the value of loc after the following code is executed? int loc; String str = "The cow jumped over the moon."; loc = str.indexOf("ov");

15

What will be the value of x after the following statements are executed? int x = 10; switch (x) { case 10: x += 15; case 12: x -= 5; break; default:x *= 3; }

20

What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; y += 20; }

210

In the following code, assume that inputFile references a Scanner object that has been successfully used to open a file: double totalIncome = 0.0; while (inputFile.hasNext()) { try { totalIncome += inputFile.nextDouble(); } System.out.println("Non-numeric" + "data encountered " + "in the file."); inputFile.nextLine(); } finally { totalIncome = 35.5; } } What will be the value of totalIncome after the following values are read from the file? 2.5 8.5 3.0 5.5 abc 1.0

35.5

If, within one try statement you want to have catch clauses of the following types, in which order should they appear in your program: (1) Exception (2) IllegalArgumentException (3) RuntimeException (4) Throwable

4, 1, 3, 2

What will be the value of pay after the following statements are executed? int hours = 45; double pay, payRate = 10.00; pay = hours <= 40 ? hours * payRate : 40 * payRate + (hours - 40) *payRate * 1.5;

475.0

What is the result of the following expression? 10 + 5 * 3 -20

5

What will be printed after the following code is executed? for (int number = 5; number <= 15; number+=3) System.out.print(number + ", ");

5, 8, 11, 14

What is the result of the following expression? 17 % 3 * 2 -12 + 15

7

What is the value of z after the following statements have been executed? int x = 4, y = 33; double z; z = (double) (y / x);

8.0

Find the error String [] words ={"Hello","Goodbye"};System.out.println(words.toUpperCase());

A subscript should be used with words, such as words[0].toUpperCase();

What will be printed after the following code is executed? String str = "abc456"; int m = 0; while ( m < 6 ) { if(Character.isLetter(str.charAt(m))) System.out.print( Character.toUpperCase(str.charAt(m))); m++; }

ABC

In the following statement, which is the subclass? public class ClassA extends ClassB implements ClassC

ClassA

In the following statement, which is the superclass (ClassA, ClassB, or ClassC)? public class ClassA extends ClassB implements ClassC

ClassB

Given the following code which of the following is TRUE? public class ClassB implements ClassA{} ClassA must override each method in ClassB or ClassB must override each method in ClassA.

ClassB must override each method in ClassA.

In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC

ClassC

If you want to append data to the existing binary file, BinaryFile.dat, write two statements to open the file.

FileOutputStream fstream = new FileOutputStream("BinaryFile.dat", true); DataOutputStream binaryOutputFile = new DataOutputStream(fstream);

What would be the value of x[1][2]?

int[][] x = {{ 55, 33, 88, 22, 99} ,{11, 44, 66, 77 }};

What would be the results of executing the following code? StringBuilder str = new StringBuilder("Little Jack Horner "); str.append("sat on the "); str.append("corner");

str would reference "Little Jack Horner sat on the corner".

What would be displayed as a result of executing the following code?| int x = 15, y = 20, z = 32; x += 12; y /= 6; z -= 14; System.out.println("x = " + x + ", y = " + y + ", z = " + z);

x = 27, y = 3, z = 18

What will be the value of a after the following code has been executed? int[] x = { 55, 33, 88, 22, 99,11, 44, 66, 77 }; int a = 10; if(x[2] > x[5]) a = 5; else a = 8;

x[2] = 88 > x[5] = 44 yes a = 5


Set pelajaran terkait

2 - Project Scope Management - Test

View Set

Social Psych Final Review (previous test answers)

View Set

AP US Chapter 19, 20 part 1, 20 part 2

View Set

Live Virtual Lab 12.1: Module 12 Authentication and Authorization Implementation Techniques

View Set

Upper and Lower Respiratory Drug Questions NUR 311 Week 9

View Set

Chapter 1 - Introduction to nursing

View Set