NEW
Font size
WorksheetsComputer Programming (Java) Mid-term
Total questions: 40
Worksheet time: 40mins
Which of the following best defines a program?
A hardware component that processes data
A collection of data stored in memory
A set of instructions that performs a specific task
A device driver for input/output operations
The process of finding and fixing errors in a program is called:
Compiling
Debugging
Executing
Testing
What is the main purpose of programming?
To perform manual calculations
To automate problem-solving through instructions
To create operating systems only
To replace computer hardware
Which of the following is NOT a programming language?
Python
C++
Java
HTML
A compiler translates:
Machine code to source code
Source code to machine code
Binary code to decimal code
Algorithm to pseudocode
What is an algorithm?
A specific Java function
A step-by-step method to solve a problem
A variable declaration
A data type
The first phase of the Software Development Life Cycle (SDLC) is:
Design
Analysis
Implementation
Requirement gathering
In problem solving, breaking down a large problem into smaller parts is called:
Compilation
Decomposition
Debugging
Abstraction
What is the output of the design phase in SDLC?
Source code
Software requirements
System architecture and specifications
User manual
Which of the following ensures a program meets user needs?
Testing phase
Design phase
Deployment phase
Maintenance phase
Which of the following best describes pseudocode?
Code written in Java
English-like statements describing program logic
Binary representation of code
A compiled file format
Java was developed by:
Microsoft
Sun Microsystems
Oracle Corporation
IBM
The extension of a Java source code file is:
.jav
.java
.class
.exe
Which method is the entry point for all Java programs?
start()
init()
run()
main()
What is the correct syntax to print text in Java?
print('Hello');
System.out.println('Hello');
System.out.println('Hello')
printf('Hello');
Which of the following is NOT a Java feature?
Platform independence
Object-oriented
Manual memory management
Robustness
Java source code is compiled into:
Binary code
Bytecode
Assembly code
Object code
The Java compiler is called:
javac
java
javadoc
jvm
The JVM is responsible for:
Compiling source code
Executing bytecode
Creating source files
Formatting output
Which keyword is used to declare a variable in Java?
var
declare
let
No keyword needed
Which of the following is a valid variable name in Java?
2name
first-name
firstName
first name
Which data type is used to store a single character?
string
char
int
boolean
What is the size of an int in Java?
8 bits
16 bits
32 bits
64 bits
Which of the following is a valid string declaration?
String name = 'John';
string name = 'John';
String name = "John";
char name = 'John';
The operator used for logical AND is:
&
&&
||
!
Which operator is used for equality comparison in Java?
=
==
!=
equals()
What will be the result of 5 + 3 * 2 in Java?
16
13
10
11
Which statement is used for decision making in Java?
loop
select
if
choice
The syntax of an if-else statement is:
if(condition){ } else{ }
if( ){ else(condition){ }
if then{ } else{ }
if() then else()
The switch statement can be used with which data types?
int, char, String
float, double
boolean only
All of the above
What is the output of below code?
int x = 10;
if(x > 5)
System.out.println('A');
else
System.out.println('B');
A
B
Error
No output
What keyword is used to stop further checking in a switch block?
stop
exit
break
end
Nested if statements are used when:
Only one condition needs to be checked
Multiple conditions depend on each other
There are no conditions
It replaces loops
Which of the following describes the “implementation” phase in the Software Development Life Cycle (SDLC)?
Gathering requirements from users
Writing and coding the program based on design
Testing for software bugs
Creating user documentation
In the SDLC, what happens during the testing phase?
The software design is created
The program is written in Java
The system is checked for errors and requirements compliance
The system is deployed to users
Which of the following best describes a constant in Java?
A variable that changes during execution
A fixed value that does not change
A user-defined data type
A Java library function
Which keyword is used in Java to define a constant?
static
final
const
define
What is the correct output of this code snippet?
int a = 5, b = 10;
if(a < b)
System.out.println("True");
else
System.out.println("False");
True
False
5
10
What is the output of String s = 'Hello'; System.out.println(s.length());
4
5
6
Error
What will be printed by System.out.println('Java'.toUpperCase());
java
JAVA
Java
Error
