wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

MIDTERM ITC-103

Total questions: 50

Worksheet time: 48mins

Name
Class
Date
1.

Defining Java Methods: What is the purpose of a return type in a Java method?

a)

It specifies the type of value that the method will return.

b)

It controls the visibility of the method.

c)

It specifies the name of the method.

d)

It determines the number of parameters the method can accept.

2.

Defining Java Methods: What is a method in Java?

a)

A method in Java is a block of code that performs a specific task and is defined within a class.

b)

A method in Java is a type of data structure

c)

A method in Java is a type of variable

d)

A method in Java is a form of loop

3.

Passing parameters to Java Methods: What are parameters in Java methods?

a)

Containers used to store the method's code

b)

Reserved keywords used to define the method's behavior

c)

Special characters used to indicate the method's return type

d)

Variables used to pass values to the method

4.

Passing parameters to Java Methods: Explain the process of passing parameters to a Java method.

a)

You declare the parameters within the parentheses of the method declaration and provide the actual values when calling the method.

b)

You declare the parameters after the method declaration

c)

You declare the parameters within the body of the method

d)

You declare the parameters in a separate file

5.

Method overloading in Java: What is method overloading in Java?

a)

When a class has multiple methods with the same name but different parameters.

b)

When a class has only one method with different parameters

c)

When a class has no methods with the same name

d)

When a class has multiple methods with the same name and same parameters

6.

Method overloading in Java: What are the rules for method overloading in Java?

a)

The return type must always be different

b)

The rules for method overloading in Java are that the methods must have the same name but different parameters, and the return type may or may not be different.

c)

The methods must have the same name and the same parameters

d)

The methods must have different names and different parameters

7.

What is the return type of a method that does not return any value?

a)

int

b)

float

c)

void

d)

double

8.

"void" and "return" can not be used together?

a)

True

b)

False

9.

In this framework, all real-world entities are represented by Classes.

a)

Functional Programming

b)

Logical Programming

c)

Object-Oriented Programming

d)

Procedural Programming

10.

Which of the following creates an object of Main class?

a)

Main obj = new Main;

b)

Main obj = new Main();

c)

Main obj = new Mian();

d)

Main obj == new Main();

11.

Which of the following is the complete syntax of creating a class?

a)

public class Main { }

b)

public class Main() { }

c)

public class Main

d)

public class Main()

12.

Another term for variable within a class

(a)  

13.

Methods are declared within a class.

a)

True

b)

False

14.

static void myMethod(){ }

What is the name of the method?

a)

static void myMethod

b)

void myMethod

c)

static myMethod

d)

myMethod

15.

Which of the following statements calls a method greetings and pass a value to that method?

a)

greetings();

b)

greeting("Hello, world!");

c)

greetings("Hello, world!");

d)

greetings(Hello, world!);

16.

Which modifiers makes a method accessible without creating an object of the class?

a)

static

b)

public

17.

Write a line of code in java that creates a method studentName that can be accessed using an object. (Parameters and return are not needed)

(a)  

18.

Write a line of code in java that declares an attribute age that has a value of 15.

(a)  

19.

Which of the following line of codes calls an attribute x within a class, and prints its value?

a)

System.out.println(x());

b)

System.out.println(x);

c)

System.out.println(obj.x)

d)

System.out.println("x");

20.

Which modifier for classes make a class accessible only by classes in the same package?

a)

private

b)

public

c)

default

d)

static

21.

What modifier makes an attribute accessible within the declared class only?

(a)  

22.

What modifier makes an attribute and methods cannot be overridden/modified?

(a)  

23.

Which component is used to compile,debug and execute the java programs ?

a)

JRE

b)

JIT

c)

JDK

d)

JVM

24.

Which of these are selection statements in java

a)

Break

b)

Continue

c)

For ( )

d)

If ( )

25.

Which one of the following is not an access modifier ?

a)

Protected

b)

Void

c)

Public

d)

Private

26.

It is an access specifier.

a)

Public

b)

Void

c)

Main

d)

Static

27.

____ keyword acknowledges the compiler that main() method does not return any value.

a)

Public

b)

Void

c)

Main

d)

Static

28.

You can make a method static by using the keyword _______.

a)

Public

b)

Void

c)

Main

d)

Static

29.

What is the return type of the main() method?

(a)  

30.

The keyword "method" is another name for

a)

an object

b)

a class

c)

a function

d)

a variable

31.

Which of the following is NOT a numeric data type

a)

int

b)

double

c)

float

d)

decimal

32.

Which of the following is incorrect?

a)

int count = 50.0;

b)

int salary = 50_000;

c)

int salary = 50_00;

d)

all of these are incorrect

33.

Where does a java program start executing instructions from:

a)

class

b)

source file

c)

main method

d)

object

34.
We are use Scanner Library in java for...
a)
Give permissions to the user
b)
Correcting software errors
c)
Allows user to read data
d)
Allows the user to enter data
35.
When we want to print in Java, we use the code ......
a)
system.out.print();
b)
System.out.println();
c)
System.Out.Printf();
d)
System.out.show();
36.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
37.
A variable that holds words
a)
String
b)
boolean
c)
int
d)
float
38.
A variable that holds a decimal number
a)
String
b)
boolean
c)
int
d)
float
39.
A variable that holds a character
a)
String
b)
boolean
c)
int
d)
char
40.
What is at the end of a line of code?
a)
#
b)
;
c)
)
d)
>
41.
These controls the behavior of a program.
a)
class
b)
object
c)
method
d)
void
42.
What does a comment look like in Java?
a)
//comment
b)
\\comment
c)
==comment
d)
\comment
43.

Consider the following code segment:


int count = 5;

double multiplier = 2.5;

int answer = (int)(count * multiplier);

answer = (answer * count) % 10;

System.out.println(answer);


What is printed as a result of executing the code segment?

a)

0

b)

2.5

c)

6

d)

12.5

e)

60

44.

What is an instance of or a copy of a class?

a)

Class

b)

Object

c)

Attribute

d)

Interface

45.

Which one(s) is/are an object?

a)

public class Rectangle

b)

Student ada = new Student();

c)

Rectangle rect = new Rectangle(10, 3);

d)

ada.reName();

46.

What is move in the following:

p1.move(2,4);

a)

Class

b)

Object

c)

Method

d)

Instance

47.

EVERY Java program MUST have these 2 essential parts in order to even RUN:

a)

a public class and the main() method

b)

a private class and the main() method

c)

a public class and at least one object

d)

a private class and at least one object

48.

In OOP the main importance is given to the

a)

methods

b)

procdures

c)

data

d)

objects

49.

What is the default value of a primitive int data type?

a)

-1

b)

null

c)

0

d)

garbage data

50.

In Java, a single-line comment starts with "/*".

a)

TRUE

b)

FALSE