quiz 7

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

Write a line of Java code that will declare a int variable named password that is initialized to the value -91.

int password = -91;

Write a line of Java code that will declare a int variable named size that is initialized to the value 62.

int size = 62;

Which of the following Java literals have the data type String? Choose all that apply. 123 3.0 3.14f "3.0" 'a' '\n' -3 false 3f "true" true 3.14

"3.0" "true"

What will this small program output? int a = 15; int b = 17; int c = 2; int x = 11; if (a <= b || a < c) { x = 19; } else { x = 5; } System.out.print(x);

19

What will be the output of this code? int a = 3; int b = 19; int c = 9; int x = 8; if (c >= b - a) { x = 18; } else { x = 2; } System.out.print(x);

2

What will this small program output? class Main { public static void foo() { x = 6; } public static int x = 16; public static void main(String[] args) { int x = 24; foo(); System.out.println(x); } }

24

What is the output of this Java program? class Driver { public static void main(String[] args) { int a = 22; int b = 0; for (int c = 5; c >= 3; c--) { b = 5; while (b > c) { b = b - 1; a = a + b; } b = b + a; } System.out.print(b); } }

36

What is the output of this Java program? class Driver { public static void main(String[] args) { int a = 15; int b = a + 12; while (a < b) { a = a + 2; b = b - 2; } System.out.print(a + b); } }

42

What is the output of this Java program? class Driver {public static void main(String[] args) { int a = 7; int b = 37; if (a < 6){ if (b > 30) System.out.print(a); else System.out.print(b); } else System.out.print(a + b); } }

44

What is the output of this Java program? class Driver { public static void main(String[] args) { int a = 81; int b = 0; for (int c = 3; c <= 5; c++) { b = 0; while (b < c) { b = b + 1; a = a - b; } b = b + a; } System.out.print(b); } }

55

What is the output of this Java program? class Driver { public static void main(String[] args) { foo(7); bar(9); } static void foo(int a) { bar(a - 1); System.out.print(a); } static void bar(int a) { System.out.print(a); } }

679

What is the output of this Java program? class Driver { public static void main(String[] args) { int a = 7; int b = 4; int c = 3; int x = 1; if (a > 1) { x = x + 700; } if (b > 2) { x = x + 40; } if (c > 2) { x = x + 3; } System.out.print(x); } }

744

What is the output of this Java program? class Driver { public static void main(String[] args) { int a = foo(3); int b = bar(3); } static int foo(int a) { a = bar(a + 4); System.out.print(a); return a; } static int bar(int a) { System.out.print(a); return a - 0; } }

773

What is the output of this Java program? class Driver { public static void main(String[] args) { int a = 95; for (int i = 1; i < 4; i++) { a = a - i; } System.out.print(a); } }

89

What will this small program output? int a = 10; int b = 18; int c = 10; int x = 7; if (a > b) { x = 4; } else if (a > c) { x = 19; } else { x = 9; } System.out.print(x);

9

When the following expression is evaluated, the result will be what Java data type? 77.31 - -18.80

double

Evaluate this expression: 3 + 3 >= 9 || 16 - 2 < 10

false

Evaluate this expression: 9 + 9 <= 1 || 10 - 8 > 6

false

Which of the following Java literals have the data type boolean? Choose all that apply. "false" "3.0" false '\n' true 314 3.14 -3 3f 3.14f "true" 'a'

false true

When the following expression is evaluated, the result will be what Java data type? 58f / 31

float


Set pelajaran terkait

Decision Support and Artificial Intelligence

View Set

Chapter 11 Exam- Commercial Crime

View Set

Ch 47: Assessment of Endocrine System

View Set

Comparing Poetry: Poetic Devices 100%

View Set

BUS498- Strategic Management Exam 1

View Set

Chapter 45: Nursing Care of the Child With an Alteration in Tissue Integrity/Integumentary Disorder

View Set

GENERAL INSURANCE PRINCIPLES class3 INSURANCE PRODUCERS

View Set