wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CMPTR 2L Midterm Exam

Total questions: 55

Worksheet time: 28mins

Name
Class
Date
1.

Attributes of an object are also known as

a)

methods

b)

properties

c)

classes

d)

functions

2.

Polymorphism related to :

a)

PPO

b)

Class

c)

OPP

d)

OOP

3.

Which from the following is a feature that allows us to perform a single action in different ways.

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

4.

The process by which objects of one class acquire the properties of objects of another class is known as

a)

Polymorphism

b)

Inheritance

c)

Data Hiding

d)

Association

5.

Hiding complexity can also be termed as

a)

Inheritance

b)

Overloading

c)

Data hiding

d)

Abstraction

6.
Which of the following concepts of OOPS means exposing only necessary information to client?
a)
Encapsulation
b)
Abstraction
c)
Data hiding
d)
Data binding
7.
How many objects can be made from a class? 
a)
None, you make classes from objects
b)
one
c)
As many as you want
d)
All of the above
8.
What is the difference between a class and an object?
a)
A class is a blueprint to make an object
b)
An object is a blueprint to make a class
c)
A blueprint is an object to make a class
d)
Blueprint class is an object make a
9.

Which one is NOT the basic element of OOP?

a)

Class

b)

Abstraction

c)

BlueJ

d)

Polymorphism

10.
An object is an instance of a:
a)
parameter
b)
method
c)
class
d)
application
11.
These have identitystate, and behavior.
a)
class
b)
object
c)
method
d)
void
12.
As a blueprint is a design for a house, a class is a design for a(n):
a)
object
b)
variable
c)
constant
d)
statement
13.
The wrapping up of data and functions into a single unit is called
a)
overloading
b)
class
c)
object
d)
encapsulation 
14.

Name of the Parent class of Mortgage and Current

a)

Account

b)

Current

c)

Mortgage

d)

Bank

15.

Select ALL subclasses

a)

Account

b)

Current

c)

Mortgage

d)

Bank

16.

+ getEndDate

+ setOverdraft


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

17.

+ getAccountNumber

+ addInterest


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

18.

-OpeningDate

-InterestRate


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

19.

Mortgage, Current and Account


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

20.
Which of the following is a mechanism by which object acquires the properties of another object?
a)
Encapsulation
b)
 Abstraction
c)
Inheritance
d)
 Polymorphism
21.

Which of the these is the functionality of ‘Encapsulation’?

a)

Binds together code and data

b)

Using single interface for general class of actions

c)

Reduce Complexity

d)

All of the mentioned

22.
The wrapping up of data and functions into a single unit is called
a)
overloading
b)
class
c)
object
d)
encapsulation 
23.

You can make changes to an object with

a)

methods

b)

attributes

c)

modifiers

d)

parameters

24.

What keyword is used to create an object?

a)

new

b)

create

c)

build

d)

start

e)

main

25.

A method is...

a)

A way of calculating things in Java

b)

A strategy for programming

c)

A predefined set of instructions in a class

d)

A way to sore details in a class

26.

What is the range of short data type in Java

a)

-128 to 127

b)

-32768 to 32767

c)

-2147483648 to 2147483647

d)

None of the mentioned

27.

2. What is the range of byte data type in Java?

a)

a) -128 to 127

b)

b) -32768 to 32767

c)

c) -2147483648 to 2147483647

d)

d) None of the mentioned

28.

An expression involving byte, int, and literal numbers is promoted to which of these?

a)

Int

b)

Long

c)

Byte

d)

Float

29.

Which of these literals can be contained in float data type variable?

a)

a) -1.7e+308

b)

b) -3.4e+038

c)

c) +1.7e+308

d)

d) -3.4e+050

30.

Which of these operators is used to allocate memory to array variable in Java?

a)

malloc

b)

alloc

c)

new

d)

new malloc

31.

Which of these is necessary to specify at time of array initialization?

a)

Row

b)

Column

c)

Both row and column

d)

None of the mentioned

32.

Which of these have highest precedence?

a)

()

b)

++

c)

*

d)

>>

33.

What should be expression1 evaluate to in using ternary operator as in this line?

expression1 ? expression2 : expression3

a)

Floating point number

b)

Integer

c)

Boolean

d)

None of the mentioned

34.

Which of these are selection statements in Java?

a)

If()

b)

For()

c)

Continue

d)

Break

35.

Which of the following is not OOPS concept in Java?

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Compliation

36.

JDK stands for?

a)

Java Data Kit

b)

Java Development Kit

c)

Java Development Kart

d)

Java Development Kind

37.

Which of the following classes belongs to lang package in Java?

a)

String, Math, Integer, Float

b)

Date, Scanner, Vector

c)

String, InputStreamReader, InputStreamWriter

d)

Button, Menu, Scrollbar, Checkbox

38.

Which of the following classes belongs to util package in Java?

a)

String, Math, Integer, Float

b)

Date, Scanner, Vector

c)

String, InputStreamReader, InputStreamWriter

d)

Button, Menu, Scrollbar, Checkbox

39.

Which function is used to input int value in Java using Scanner class?

a)

scanner_object . nextInteger( )

b)

scanner_object . nextInt( )

c)

scanner_object . nextint( )

d)

scanner_object . NextInt( )

40.

Which function is used to input float value in Java using Scanner class?

a)

scanner_object . nextFloat( )

b)

scanner_object . nextInt( )

c)

scanner_object . nextfloat( )

d)

scanner_object . NextFloat( )

41.

Which function is used to input String value in Java using Scanner class?

a)

scanner_object . nextLine( )

b)

scanner_object . nextString( )

c)

scanner_object . nextText( )

d)

scanner_object . nextChar( )

42.

Package is a collection of __________ .

a)

Objects

b)

Classes and Interfaces

c)

Data

d)

Variables and Constants

43.

Select TWO correct ways of including (importing) package in our program?

a)

import package_name . java . *;

b)

import java . package_name . *;

c)

include java . package_name . *;

d)

import java . package_name . Class_Name;

44.

Java is Truly (Pure) _____________ Language?

a)

OOP

b)

POP

c)

Object Based

d)

All of the given

45.

Which is NOT the access specifier (visibility mode) in Java?

a)

private

b)

protected

c)

friendly

d)

publicly

46.
USE THIS TYPE OF DECISION STATEMENT IF YOU WANT TO EXECUTE ONE SET OF STATEMENTS ON THE TRUE PATH AND AN ALTERNATE SET OF STATEMENTS ON THE FALSE PATH.
a)
if statement (binary bypass)
b)
if else statement (binary choice)
c)
switch statement (multiple choice)
d)
nested if statement
47.
WHICH TYPE OF DECISION STRUCTURE IS THIS?
if (x==10)
{
          if (y==20)
          {
                    System.out.println("Coordinates: 10, 20");
          }
}
a)
Switch
b)
If Else if 
c)
If else (binary choice)
d)
Nested If
48.
WHAT DECISION STRUCTURE WORKS BEST IF YOU HAVE MORE THAN TWO POSSIBLE ANSWERS (MULTIPLE CHOICE) TO A QUESTION, AND THOSE ANSWERS CAN BE INTEGER OR CHARACTER BASED?
a)
Nested If Statements
b)
An If statement
c)
A Switch statement
d)
If else if statements
49.
WHAT IS MISSING FROM THIS SWITCH STATEMENT THAT WILL CAUSE ALL STATEMENTS ON EVERY CASE PATH TO EXECUTE ONCE A SUITABLE ANSWER IS CHOSEN?
switch (flavor)
{
     case 'V':
          cone="Vanilla";
     case 'C':
          cone="Chocolate";
     case 'S':
          cone="Strawberry";
     default:
          cone="Empty";
}
a)
The case clause
b)
The break clause
c)
The continue clause
d)
The default clause
50.
WHICH OF THE FOLLOWING IS THE RELATIONAL OPERATOR FOR NOT EQUAL TO?
a)
>=
b)
<>
c)
\=
d)
!=
51.
WHICH OF THE FOLLOWING IS THE LOGICAL OPERATOR FOR AN AND RELATIONSHIP?
a)
!
b)
&&
c)
||
d)
&
52.
WHICH OF THE FOLLOWING STATEMENTS WOULD VALIDLY COMPARE TWO STRINGS FOR ONLY AN EXACT EQUALITY MATCH?
a)
if (myName==yourName)
b)
if (myName.compareTo(yourName))
c)
if (myName.equals(yourName))
d)
if (myName.compareToIgnoreCase(yourName))
53.
WHICH METHOD WOULD ALLOW YOU TO COMPARE TWO STRINGS FOR AN EXACT EQUALITY MATCH REGARDLESS OF WHETHER OR NOT ONE OF THE STRINGS IS ALL CAPITALIZED AND THE OTHER IS ALL LOWERCASE?
a)
if (myName.equals(yourName))
b)
if (myName.equalsIgnoreCase(yourName))
c)
if (myName.compareTo(yourName))
d)
None of the above
54.
WHAT DOES THE FOLLOWING CONDITIONAL EXPRESSION DO?
grandTotal = (itemTaxable == 'Y') ? 10.60 : 10.00;
a)
Process a if statement using shorthand notation
b)
Assign 10.60 to grandTotal if the item is taxable
c)
Assign 10.00 to grandTotal if the item is not taxable
d)
All of the above
55.
Which method allows you to display formatted content on the screen, such that you can control whether or not a numeric value has a decimal point and how many decimal places are allowed?
a)
String.format()
b)
System.out.println()
c)
System.out.printf()
d)
None of these