NEW
Font size
WorksheetsComputer Programming 1 Review
Total questions: 30
Worksheet time: 10mins
How will you import the class Reader from the java.io package?
import java;io;Reader;
import java*io*Reader;
import java.io.Reader;
import java.io_Reader;
This is a visual representation of a problem-solving approach that contains symbols or shapes describing how a process operates.
Algorithm
Pseudocode
Flowchart
Programming Methodology
Which of the following is used to provide explanations in a program and is ignored by the compiler?
Import Statements
Comments
Packages
Identifiers
Which best describes the main method in Java?
public static void main (String[] args){}
public static main void (String[] args){}
private static void main (String[] args){}
public void main (String[] args){}
This is the bug in a program that occurs when the program produces an incorrect output.
Syntax error
Logical Error
Program Error
Debug
Which is NOT TRUE about naming an identifier?
It must not begin with digits.
It must not contain a dollar sign character.
It must not be a reserved word.
It must not contain white spaces.
Which is the argument in the following statement:
int x = rand.nextInt(10);?
rand
int x
nextInt
10
What will be the error message when the following statement is compiled:
System.out.println("Compiling Java Program');?
Missing semicolon
Unclosed string literal
Cannot find method
No suitable method found
This tells a compiler to print the variable with a specific format?
Format Print Method
Format Specifier
Formatting
Format Output
It is a procedure of converting a value of a specific data type to a different data type?
Type Costing
Type Casting
Conversion
Constant Conversion
It is an InputStream in Java connected to the standard input device, which is the keyboard.
System.int
System.out
System.input
System.in
This expression returns a Boolean value when evaluated.
Arithmetic expression
Floating-point expression
Logical expression
Mixed expression
What direction does a logical expression with two (2) or more logical operators evaluated follow?
From left to right
From inside a parentheses
From right to left
From outside a parentheses
This is used to specify a set a value and their operations.
Variable
Constant
Data Type
Memory Location
It is a memory location whose values can be changed during program execution.
Variable
Constant
Data Type
Memory
These operators are used to perform basic mathematical operations.
Relational Operators
Logical Operators
Assignment Operators
Arithmetic Operators
Which operators are used to assign a value to a variable?
Assignment Operators
Logical Operators
Arithmetic Operators
Relational Operators
Which of the following statements is correct in printing the variable age using the printf() method?
System.out.printf("Your age is %.2f" + age);
System.out.printf("Your age is %.2f");
System.out.printf("Your age is %.2f" age);
System.out.printf("Your age is %.2f", age);
Which assignment operator adds 1 to a variable?
+=
%=
++
*=
Which method is used to retrieve user input as a String or text?
nextDouble()
nextShort()
nextLong()
nextLine()
It is an expression that returns a numeric value and consists of arithmetic operators.
Arithmetic Expression
Logical Expression
Mixed Expression
Relational Expression
What is the value of variable a when the following statements are executed?
int a = 4; a++; a*=3;
4
5
15
Compilation Error
Which of the following statements is a valid variable name declaration?
int var.Name;
int var Name;
int _varName;
int 1varName;
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();
2
2.0
null
Compilation Error
This String method changes every occurrence of a given character and returns a new string?
substring()
replace()
trim()
charAt()
Which is the correct form of an if statement?
if (condition) {//statements}
if { (condition) //statements}
if { //statements}(condition)
if {//statements (condition)}
In what Java package the String class is located?
java.util
java.io
java.lang
java.awt
These are statements grouped together in curly braces?
Multiple Statements
Compound Statements
Control Structures
Control Statements
Which control structure executes a particular series of statements depending on a given condition?
One-way Structure
Selection Structure
Repetition Structure
Two-way Structure
Which control structure repeats a series of statements a certain number of times depending on a given condition?
One-way Structure
Selection Structure
Repetition Structure
Two-way Structure
