wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Computer Programming (Java) Mid-term

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

Which of the following best defines a program?

a)

A hardware component that processes data

b)

A collection of data stored in memory

c)

A set of instructions that performs a specific task

d)

A device driver for input/output operations

2.

The process of finding and fixing errors in a program is called:

a)

Compiling

b)

Debugging

c)

Executing

d)

Testing

3.

What is the main purpose of programming?

a)

To perform manual calculations

b)

To automate problem-solving through instructions

c)

To create operating systems only

d)

To replace computer hardware

4.

Which of the following is NOT a programming language?

a)

Python

b)

C++

c)

Java

d)

HTML

5.

A compiler translates:

a)

Machine code to source code

b)

Source code to machine code

c)

Binary code to decimal code

d)

Algorithm to pseudocode

6.

What is an algorithm?

a)

A specific Java function

b)

A step-by-step method to solve a problem

c)

A variable declaration

d)

A data type

7.

The first phase of the Software Development Life Cycle (SDLC) is:

a)

Design

b)

Analysis

c)

Implementation

d)

Requirement gathering

8.

In problem solving, breaking down a large problem into smaller parts is called:

a)

Compilation

b)

Decomposition

c)

Debugging

d)

Abstraction

9.

What is the output of the design phase in SDLC?

a)

Source code

b)

Software requirements

c)

System architecture and specifications

d)

User manual

10.

Which of the following ensures a program meets user needs?

a)

Testing phase

b)

Design phase

c)

Deployment phase

d)

Maintenance phase

11.

Which of the following best describes pseudocode?

a)

Code written in Java

b)

English-like statements describing program logic

c)

Binary representation of code

d)

A compiled file format

12.

Java was developed by:

a)

Microsoft

b)

Sun Microsystems

c)

Oracle Corporation

d)

IBM

13.

The extension of a Java source code file is:

a)

.jav

b)

.java

c)

.class

d)

.exe

14.

Which method is the entry point for all Java programs?

a)

start()

b)

init()

c)

run()

d)

main()

15.

What is the correct syntax to print text in Java?

a)

print('Hello');

b)

System.out.println('Hello');

c)

System.out.println('Hello')

d)

printf('Hello');

16.

Which of the following is NOT a Java feature?

a)

Platform independence

b)

Object-oriented

c)

Manual memory management

d)

Robustness

17.

Java source code is compiled into:

a)

Binary code

b)

Bytecode

c)

Assembly code

d)

Object code

18.

The Java compiler is called:

a)

javac

b)

java

c)

javadoc

d)

jvm

19.

The JVM is responsible for:

a)

Compiling source code

b)

Executing bytecode

c)

Creating source files

d)

Formatting output

20.

Which keyword is used to declare a variable in Java?

a)

var

b)

declare

c)

let

d)

No keyword needed

21.

Which of the following is a valid variable name in Java?

a)

2name

b)

first-name

c)

firstName

d)

first name

22.

Which data type is used to store a single character?

a)

string

b)

char

c)

int

d)

boolean

23.

What is the size of an int in Java?

a)

8 bits

b)

16 bits

c)

32 bits

d)

64 bits

24.

Which of the following is a valid string declaration?

a)

String name = 'John';

b)

string name = 'John';

c)

String name = "John";

d)

char name = 'John';

25.

The operator used for logical AND is:

a)

&

b)

&&

c)

||

d)

!

26.

Which operator is used for equality comparison in Java?

a)

=

b)

==

c)

!=

d)

equals()

27.

What will be the result of 5 + 3 * 2 in Java?

a)

16

b)

13

c)

10

d)

11

28.

Which statement is used for decision making in Java?

a)

loop

b)

select

c)

if

d)

choice

29.

The syntax of an if-else statement is:

a)

if(condition){ } else{ }

b)

if( ){ else(condition){ }

c)

if then{ } else{ }

d)

if() then else()

30.

The switch statement can be used with which data types?

a)

int, char, String

b)

float, double

c)

boolean only

d)

All of the above

31.

What is the output of below code?

int x = 10;

if(x > 5)

System.out.println('A');

else

System.out.println('B');

a)

A

b)

B

c)

Error

d)

No output

32.

What keyword is used to stop further checking in a switch block?

a)

stop

b)

exit

c)

break

d)

end

33.

Nested if statements are used when:

a)

Only one condition needs to be checked

b)

Multiple conditions depend on each other

c)

There are no conditions

d)

It replaces loops

34.

Which of the following describes the “implementation” phase in the Software Development Life Cycle (SDLC)?

a)

Gathering requirements from users

b)

Writing and coding the program based on design

c)

Testing for software bugs

d)

Creating user documentation

35.

In the SDLC, what happens during the testing phase?

a)

The software design is created

b)

The program is written in Java

c)

The system is checked for errors and requirements compliance

d)

The system is deployed to users

36.

Which of the following best describes a constant in Java?

a)

A variable that changes during execution

b)

A fixed value that does not change

c)

A user-defined data type

d)

A Java library function

37.

Which keyword is used in Java to define a constant?

a)

static

b)

final

c)

const

d)

define

38.

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");

a)

True

b)

False

c)

5

d)

10

39.

What is the output of String s = 'Hello'; System.out.println(s.length());

a)

4

b)

5

c)

6

d)

Error

40.

What will be printed by System.out.println('Java'.toUpperCase());

a)

java

b)

JAVA

c)

Java

d)

Error