1.1.5 Intro to programming quiz review

1.1.5 Intro to programming quiz review

9th - 12th Grade

8 Qs

quiz-placeholder

Similar activities

WJEC GCSE ICT Unit 1 E-Mail

WJEC GCSE ICT Unit 1 E-Mail

9th - 10th Grade

13 Qs

Scratch

Scratch

KG - Professional Development

10 Qs

Java: repetition control structure for & while

Java: repetition control structure for & while

10th - 12th Grade

10 Qs

Lesson 1 Introduction to Database System

Lesson 1 Introduction to Database System

10th Grade

10 Qs

Week 2 ( Prepare Hand Tools)

Week 2 ( Prepare Hand Tools)

9th Grade

10 Qs

Review

Review

9th - 12th Grade

10 Qs

PowerPoint Quiz 2

PowerPoint Quiz 2

9th Grade

13 Qs

Year 10 IT - CN - Key Words

Year 10 IT - CN - Key Words

8th - 11th Grade

10 Qs

1.1.5 Intro to programming quiz review

1.1.5 Intro to programming quiz review

Assessment

Quiz

Computers

9th - 12th Grade

Hard

Created by

Michael Courtright

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Consider the following code segment in the image

1

0.0

1.0

8.0

0.0

Answer explanation

In the following statements, the values of variables a, b, and c are plugged into this expression: a b / c a / b c

int a = 5;

int b = 4;

int c = 2;

double x = a b / c a / b c;

The expression is evaluated using the precedence of operators, as follows:

a b / c a / b c

= 5 4 / 2 5 / 4 2 // 5 / 4 is 1, as it is integer division.

= 20 / 2 1 * 2 // 20 / 2 is 10, as

it is integer division.

= 10 2

= 8

8 is assigned to double type variable x, therefore the output is 8.0.

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Answer the question in the image

10 11 45 25

10 11 46 25

10 11 47 26

10 10 46 25

10 10 40 20

Answer explanation

The execution of the statements is as follows:

int score = 10; // The value of 10 is assigned to the variable score.

System.out.print(score  + " ");

// The value of score, 10, is displayed and followed by a space.

System.out.print(score++  + " ");

/* The value of score, 10, is then incremented to 11. */

score *= 2;

// The value of score, 11, is doubled, making it 22.

System.out.print(++score*2  + " ");

/* The value of score is incremented to 23 first, so 46 is displayed.

*/ int penalty = 4;

// The value of 4 is assigned to penalty. score += penalty/2;

// The result of 4/2 = 2 is added to score, making it 25.

System.out.print(score  + " ");

// 25 is displayed.

So, the complete output is 10 10 46 25.

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

How many bytes are occupied by a variable of the int data type in the Java programming language?

1

2

4

8

16

Answer explanation

An int data type variable in Java occupies 4 bytes of memory.

4.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

final float PI = 3.14;

System.out.println("The volume of a cylinder is: " + (PI*radius*radius*height) );

int PI = 3.14;

System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );

final double pi = 3.14;

System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );

final double PI = 3.14;

System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );

final double PI;

System.out.println("The volume of a cylinder is: "+ (PI*radius*radius*height) );

Answer explanation

The value of pi is constant, so the desired output requires the usage of the final keyword for declaring a named constant.

Choice D declares a named constant PI with the appropriate data type and uses it to display the output as required.

Choice A is not correct, as the declaration statement is assigning a double value to a float type constant, which will generate a syntax error. Recall that floating type literals are of the double data type by default in Java.

Choice B does not declare a named constant.

Choice C will generate a syntax error, as the declaration statement declares the named constant as pi and uses PI in System.out.println().

Choice E will generate a syntax error, as the declaration statement does not assign a constant value.

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following statements is true?

Integer variables cannot be used as an operand for the / operator.

The data type of a variable is used to determine where the variable is stored in computer memory when the program is executed.

In Java, the data types in the declaration statements of named constants are needed only for documentation purposes.

The data type of a variable determines the kind of operations that can be performed on the variable.

Variables of the float data type are represented in memory as strings of decimal digits with a decimal point and an optional sign.

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Media Image

Answer the question in the image.

Happy New YearWelcome 2022

Happy New Year Welcome2022

HappyNewYearWelcome2022

Welcome 2022 Happy New Year

Happy New Year Welcome 2022

7.

MULTIPLE CHOICE QUESTION

1 min • 5 pts

Which of the following data types is the correct option for creating a variable that can be assigned the numeric value 345.67?

double

boolean

int

byte

char

8.

FILL IN THE BLANK QUESTION

3 mins • 3 pts

What will be the final answer to the following arithmetic expression if it is evaluated using rules of operator precedence and associativity?

y += u + v * w/x z

where u = 5, v = 3, w= 4, x= 6, z = 2.

Assume all variables are of integer data type.

Answer explanation

y += u + v * w/x z

where u = 5, v = 3, w= 4, x= 6, z = 2.

y += 5 + (3 * 4)/6 - 2

y += 5 + (12/6) -2

y += (5 + 2) - 2

y += (7 - 2)

y += 5

*Can't go any further, since we don't know the value of y