wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Computer Programming 1 Review

Total questions: 30

Worksheet time: 10mins

Name
Class
Date
1.

How will you import the class Reader from the java.io package?

a)

import java;io;Reader;

b)

import java*io*Reader;

c)

import java.io.Reader;

d)

import java.io_Reader;

2.

This is a visual representation of a problem-solving approach that contains symbols or shapes describing how a process operates.

a)

Algorithm

b)

Pseudocode

c)

Flowchart

d)

Programming Methodology

3.

Which of the following is used to provide explanations in a program and is ignored by the compiler?

a)

Import Statements

b)

Comments

c)

Packages

d)

Identifiers

4.

Which best describes the main method in Java?

a)

public static void main (String[] args){}

b)

public static main void (String[] args){}

c)

private static void main (String[] args){}

d)

public void main (String[] args){}

5.

This is the bug in a program that occurs when the program produces an incorrect output.

a)

Syntax error

b)

Logical Error

c)

Program Error

d)

Debug

6.

Which is NOT TRUE about naming an identifier?

a)

It must not begin with digits.

b)

It must not contain a dollar sign character.

c)

It must not be a reserved word.

d)

It must not contain white spaces.

7.

Which is the argument in the following statement:
int x = rand.nextInt(10);?

a)

rand

b)

int x

c)

nextInt

d)

10

8.

What will be the error message when the following statement is compiled:
System.out.println("Compiling Java Program');?

a)

Missing semicolon

b)

Unclosed string literal

c)

Cannot find method

d)

No suitable method found

9.

This tells a compiler to print the variable with a specific format?

a)

Format Print Method

b)

Format Specifier

c)

Formatting

d)

Format Output

10.

It is a procedure of converting a value of a specific data type to a different data type?

a)

Type Costing

b)

Type Casting

c)

Conversion

d)

Constant Conversion

11.

It is an InputStream in Java connected to the standard input device, which is the keyboard.

a)

System.int

b)

System.out

c)

System.input

d)

System.in

12.

This expression returns a Boolean value when evaluated.

a)

Arithmetic expression

b)

Floating-point expression

c)

Logical expression

d)

Mixed expression

13.

What direction does a logical expression with two (2) or more logical operators evaluated follow?

a)

From left to right

b)

From inside a parentheses

c)

From right to left

d)

From outside a parentheses

14.

This is used to specify a set a value and their operations.

a)

Variable

b)

Constant

c)

Data Type

d)

Memory Location

15.

It is a memory location whose values can be changed during program execution.

a)

Variable

b)

Constant

c)

Data Type

d)

Memory

16.

These operators are used to perform basic mathematical operations.

a)

Relational Operators

b)

Logical Operators

c)

Assignment Operators

d)

Arithmetic Operators

17.

Which operators are used to assign a value to a variable?

a)

Assignment Operators

b)

Logical Operators

c)

Arithmetic Operators

d)

Relational Operators

18.

Which of the following statements is correct in printing the variable age using the printf() method?

a)

System.out.printf("Your age is %.2f" + age);

b)

System.out.printf("Your age is %.2f");

c)

System.out.printf("Your age is %.2f" age);

d)

System.out.printf("Your age is %.2f", age);

19.

Which assignment operator adds 1 to a variable?

a)

+=

b)

%=

c)

++

d)

*=

20.

Which method is used to retrieve user input as a String or text?

a)

nextDouble()

b)

nextShort()

c)

nextLong()

d)

nextLine()

21.

It is an expression that returns a numeric value and consists of arithmetic operators.

a)

Arithmetic Expression

b)

Logical Expression

c)

Mixed Expression

d)

Relational Expression

22.

What is the value of variable a when the following statements are executed?
int a = 4; a++; a*=3;

a)

4

b)

5

c)

15

d)

Compilation Error

23.

Which of the following statements is a valid variable name declaration?

a)

int var.Name;

b)

int var Name;

c)

int _varName;

d)

int 1varName;

24.

What is the value of variable d when the following statements are executed and the user input is 2?
Scanner scan = new Scanner(System.in);
double d = scan.nextDouble();

a)

2

b)

2.0

c)

null

d)

Compilation Error

25.

This String method changes every occurrence of a given character and returns a new string?

a)

substring()

b)

replace()

c)

trim()

d)

charAt()

26.

Which is the correct form of an if statement?

a)

if (condition) {//statements}

b)

if { (condition) //statements}

c)

if { //statements}(condition)

d)

if {//statements (condition)}

27.

In what Java package the String class is located?

a)

java.util

b)

java.io

c)

java.lang

d)

java.awt

28.

These are statements grouped together in curly braces?

a)

Multiple Statements

b)

Compound Statements

c)

Control Structures

d)

Control Statements

29.

Which control structure executes a particular series of statements depending on a given condition?

a)

One-way Structure

b)

Selection Structure

c)

Repetition Structure

d)

Two-way Structure

30.

Which control structure repeats a series of statements a certain number of times depending on a given condition?

a)

One-way Structure

b)

Selection Structure

c)

Repetition Structure

d)

Two-way Structure