2.1 programming building blocks

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

write the code to declare a boolean variable named a and assign a the value false.

boolean a = false;

what is the output of this code sequence? float a = 13f; System.out.println( a );

13.0 or 13

What is the output of this code sequence? int a = 13 % 5; System.out.println( a );

3

what is the output of this code sequence? int a = 5; System.out.println( a-- );

5

where is the error in this code sequence? double a = 45.2; float b = a;

cannot assign a double to a float variable (possible loss of precision).

what is the output of this code sequence? double a = 12.5; System.out.println( a );

12.5

write the code to calculate the average of two int variables a and b and print the result. The average should be printed as a floating-point number.

double average = (a + b)/2.0; System.out.println("Average = " + average);

where is the error in this code sequence? int a = 5; a - = 4;

there should not be a space between - and =.

what is the output of this code sequence? int a = 12 / ( 6 * 2 ); System.out.println( a );

1

what is the output of this code sequence? int a = 5; a /= 6; System.out.println( a );

0

write the code to declare a char variable named a and assign a the character B

CHAR A = B

write the code to declare a float variable named a and assign a the value 34.2?

FLOAT A = 34.2

write the code to calculate the total of three int variables a, b, and c and print the result.

int a = 3; int b = 5; int c = 8; System.out.println(a+b+c);

what is the valid way to declare an integer variable named a?

int a;

What is the output of this code sequence? double a = (double) (12) / 5; System.out.println( 0 );

2

what is the output of this code sequence? double a = (double) (12 / 5); System.out.println( a );

2

what is the output of this code sequence? int a = (int) 12.0 / 5; System.out.println( a );

2

what is the output of this code sequence? int a = 13 / 5; System.out.println( a );

2

What is the output of this code sequence? double a = 13 / 5; System.out.println( a );

2.0

what is the output of this code sequence? double a = 12.0 / 5; System.out.println( a );

2.0

what is the output of this code sequence? int a = 12 / 6 * 2; System.out.println( a );

4

what is the output of this code sequence? int a = 5; System.out.println( --a);

4

What is the output of this code sequence? int a = ( 4 + 6 ) / 2; System.out.println( a );

5

What is the output of this code sequence? int a = 5; a++; System.out.println( a );

6

what is the output of this code sequence? int a = 6; System.out.println( a );

6

What is the output of this code sequence? int a = 4 + 6 / 2; System.out.println( a );

7

what is the output of this code sequence? int a = 5; a += 2; System.out.println( a );

7

write the code to assign the value 10 to an int variable named a.

INT A = 10 int a;

write the code to calculate and print the remainder of the division of two int variables with the values 10 and 3 (the value printed will be 1).

System.out.println(a%b);

given there declared and initialized int variables a, b, and c, which of the following statements are valid?

a = b;, a = 67, b = 8.7; , c = a - b; and c = a / 2.3; , a += c;

which of the following identifiers are valid?

a, sales, sales&profit, inter, doubleSales, TAX_RATE.


संबंधित स्टडी सेट्स

PICU Prep Board Review Questions 2010

View Set

SMSH-PROJECTS-HALF LIFE CALCULATIONS-10/12/23

View Set

NUR 236 PrepU Chapter 36: Pain Management in Children

View Set

MicroEcon TESTS (1,2,3) - Final 22

View Set

Java Programming - Chapter 7: Arrays

View Set

Biology - Quiz 2: Properties of Compounds

View Set