wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PRELIMINARY EXAMINATION [OOP]

Total questions: 85

Worksheet time: 52mins

Name
Class
Date
1.
The most basic circuitry-level computer language, which consists of on and off switches, is _____________.
a)
a high-level language
b)
machine language
c)
Java
d)
C++
2.
Languages that let you use a vocabulary of descriptive terms, such as read, write, or add, are known as _____________ languages.
a)
high-level
b)
machine
c)
procedural
d)
object-oriented
3.
The rules of a programming language constitute its _____________.
a)
objects
b)
logic
c)
format
d)
syntax
4.
A _____________ translates high-level language statements into machine code.
a)
programmer
b)
syntax detector
c)
compiler
d)
decipherer
5.
Named computer memory locations are called _____________.
a)
compilers
b)
variables
c)
addresses
d)
appellations
6.
The individual operations used in a computer program are often grouped into logical units called _____________.
a)
procedures
b)
variables
c)
constants
d)
logistics
7.
Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of _____________.
a)
command-line operating systems
b)
procedural programming
c)
object-oriented programming
d)
machine languages
8.
The values of an object’s attributes also are known as its _____________.
a)
state
b)
orientation
c)
methods
d)
condition
9.
An instance of a class is a(n) _____________.
a)
procedure
b)
method
c)
class
d)
object
10.
Java is architecturally _____________.
a)
specific
b)
oriented
c)
neutral
d)
abstract
11.
You must compile classes written in Java into _____________.
a)
bytecode
b)
source code
c)
javadoc statements
d)
object code
12.
All Java programming statements must end with a _____________.
a)
period
b)
comma
c)
semicolon
d)
closing parenthesis
13.
Arguments to methods always appear within _____________.
a)
parentheses
b)
double quotation marks
c)
single quotation marks
d)
curly braces
14.
In a Java program, you must use _____________ to separate classes, objects, and methods.
a)
comas
b)
semicolons
c)
dots
d)
forward slashes
15.
Nonexecuting program statements that provide documentation are called _____________.
a)
classes
b)
notes
c)
commands
d)
comments
16.
All Java applications must have a method named _____________.
a)
method()
b)
main()
c)
java()
d)
Hello()
17.
Java supports three types of comments: _____________, _____________,and javadoc.
a)
line, block
b)
string, literal
c)
constant, variable
d)
single, multiple
18.
After you write and save a Java application file, you _____________ it.
a)
interpret and then compile
b)
interpret and then execute
c)
compile and then resave
d)
compile and then interpret
19.
The command to execute a compiled Java application is _____________.
a)
run
b)
execute
c)
javac
d)
java
20.
You save text files containing Java source code using the file extension _____________.
a)
.java
b)
.class
c)
.txt
d)
.src
21.
Unlike a low-level programming language, a high-level programming language allows you to use a vocabulary of reasonable terms instead of the sequences of on and off switches that perform the corresponding tasks.
a)
True
b)
False
22.
Polymorphism is the ability to create classes that share the attributes and methods of existing classes, but with more specific features.
a)
True
b)
False
23.
Java programs that are embedded in a Web page are called applets, while stand-alone programs are called Java applications.
a)
True
b)
False
24.
In the method header public static void main(String[] args), the word static means that a method is accessible and usable, even though no objects of the class exist.
a)
True
b)
False
25.
Line comments start with two forward slashes ( // ) and end with two backslashes ( // ); they can extend across as many lines as needed.
a)
True
b)
False
26.
In Java, if a class is public, you must save the class in a file with exactly the same name and a .java extension.
a)
True
b)
False
27.
A dialog box is a GUI object resembling a window in which you can place messages you want to display.
a)
True
b)
False
28.
Syntax errors are more difficult to find and resolve than logic errors.
a)
True
b)
False
29.
What is a program?
a)
a set of instructions that you write to tell a computer what to do
b)
translates language statements into machine code.
c)
a style of programming in which sets of operations are executed one after another in sequence.
30.
Refers to the hiding of data and methods within an object.
a)
Encapsulation
b)
Attributes
c)
Object
31.
A variable is a named memory location that you can use to store a value; it can hold only one value at a time, but the value it holds can change.
a)
True
b)
False
32.
A variable of type int can hold any whole number value from approximately negative two billion to positive two billion.
a)
True
b)
False
33.
An expression that contains a relational operator has a Boolean value.
a)
True
b)
False
34.
A floating-point constant, such as 5.6, is a float by default.
a)
True
b)
False
35.
To store a string of characters, you use a data structure called a Text; string constants are written between parentheses.
a)
True
b)
False
36.
The arithmetic operators are examples of unary operators, which are so named because they perform one operation at a time.
a)
True
b)
False
37.
You can explicitly override the unifying type imposed by Java by performing a type cast; type casting forces a value of one data type to be used as a value of another type.
a)
True
b)
False
38.
System.in is more flexible than System.out because it can read all the basic Java data types.
a)
True
b)
False
39.
A whole number without decimal places.
a)
Floating Point
b)
Integer
c)
Boolean
40.
It describes values that cannot be changed during the execution of an application.
a)
Variable
b)
Primitive Type
c)
Constant
41.
Any class can contain an unlimited number of methods, and each method can be called an unlimited number of times.
a)
True
b)
False
42.
Any class can contain an unlimited number of methods, and each method can be called an unlimited number of times.
a)
True
b)
False
43.
A class is an instantiation of many objects.
a)
True
b)
False
44.
A class header contains an optional access specifier, the keyword class, and an identifier.
a)
True
b)
False
45.
Static methods are instance methods.
a)
True
b)
False
46.
When you declare an object, you give it a name and set aside enough memory for the object to be stored.
a)
True
b)
False
47.
You can place a class’s fields first within the class, followed by methods.
a)
True
b)
False
48.
Unlike a primitive variable, an instantiated object cannot be passed into or returned from a method.
a)
True
b)
False
49.
A program module that contains a series of statements that carry out a task.
a)
Method
b)
Declaration
c)
Implementation
50.
Is the programming feature that allows you to use a method name to encapsulate a series of statements.
a)
Access Modifier
b)
Formal Parameters
c)
Abstraction
51.

Describe method.

a)

A component of a program in a big program.

b)

A program to perform a specific task.

c)

A component of a program written to perform a specific task.

d)

A variable that use to read an input.

52.

There two (2) types of method which are

a)

return

b)

Standard library

c)

User defined

d)

non-return

53.

This is a general structure a method.

a)

<Returnvalue type> <Method Name> (argument / s)

b)

<Modifier> < type> <Method Name> (parameter / s)

c)

public static void main (String[ ] args)

d)

<Method Name> (parameter)

54.

This is an example of a non-return method.

a)

True

b)

False

55.

In which line is representing the meaning of Standard library method.

a)

Line 2

b)

Line 8

c)

Line 13

d)

Line 10

56.

Identify the line with syntax error.

a)

Line 8 and Line 15

b)

Line 10 only

c)

Line 6, Line 8, Line 10

d)

Line 8, Line 11 and Line 15

57.

The name of this method is ....

a)

Oddsum

b)

int Oddsum

c)

int Oddsum (int number)

d)

return totaloddsum

58.

Data type for non return method is

a)

int

b)

double

c)

void

d)

public static

59.

Fix the syntax error in Line 8.

a)

Cylinder sc = new System.in( );

b)

Scanner sc = new Scanner (System.in);

c)

Cylinder Volume = new Volume( );

d)

Cylinder call = new Cylinder( );

60.

Fix all the syntax error. Your answer may more than 1.

a)

Circle mtd = new Circle ( );

b)

r=sc.nextInt( );

c)

void Area (double r);

d)

double r;

61.

1. Which of this method is given parameter via command line arguments?

a)

a) main()

b)

b) recursive() method

c)

c) Any method

d)

d) System defined methods

62.

What are the Type Conversions available in Java language?

a)

A) Narrowing Type Conversion

b)

B) Widening Type Conversion

c)

A and B

d)

D) None of the above

63.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

64.

Which type of loop is best known for its boolean condition that controls entry to the loop?

a)

A. do-while loop

b)

B. for (traditional)

c)

C. for-each

d)

D. while

65.

What will be the Output of the below code:

public class Demo{

public static void main(String[] arr){

}

public static void main(String arr){

}

}

a)

a) Nothing

b)

b) Error

c)

C) Finite

d)

d) Hii

66.

char is 2 byte in storage?

a)

True

b)

False

67.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

68.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

69.
What data type would be best used to record an email address?
a)
String
b)
Integer
c)
Real
d)
Character
70.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

71.

What is the output of the following code snippet?

int i = 0; for(i = 0 ; i < 5; i++)

{ }

System.out.println(i);

a)

A. 5

b)

B. 0

c)

C. 4

d)

D. Compilation Error

72.

Function of the Scanner class to accept a float literal from the user is

a)

nextInt( )

b)

hasNext( )

c)

next( )

d)

nextFloat( )

73.

Predict the value of k,

int k =10;

k=k+k++;

a)

11

b)

20

c)

21

d)

22

74.
Which of these is not a Thread state?
a)
New
b)
Runnable
c)
sleep
d)
terminated
75.

Which of the following key word is optional in Exception handling program

a)

try

b)

catch

c)

finally

d)

throw

76.

What is an exception

a)

Error occurred during the execution of a program

b)

Bug occurred during the compile time of a program

c)

Simply an Error

d)

It is related to input values

77.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

78.

Choose an exception if attempt to divide number by zero


int number = 89 / 0;

System.out.println("The answer is " + number);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundException

79.

class exception_handling

{ public static void main(String args[])

{ try

{ int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

} catch(ArithmeticException e)

{ System.out.print("B");

}

finally

{ System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

80.

Find the output for the following.

public class IncDec

{

public static void main(String s[])

{

int a = 1;

int b = 2;

int c;

int d;


c = ++b;

d = a++;


c++;


System.out.println("a = " + a);

System.out.print("b = " + b);

System.out.println("c = " + c);

System.out.print("d = " + d);

}

}

a)

a = 2 b = 3 c = 4 d = 1

b)

a = 2 b = 3 c = 4 d = 1

c)

Program does not compile.

d)

a = 1 b = 2 c = 4 d = 2

81.

What method do you use to read a string input from the user using Scanner?

a)

nextLine()

b)

readLine()

c)

readString()

d)

inputString()

82.

Which method is used to read an integer input from the user using Scanner?

a)

nextInt()

b)

readInt()

c)

inputInt()

d)

getInt()

83.

What happens if you try to read an integer using nextInt() but the input is not an integer?

a)

It throws a NoSuchElementException

b)

It returns 0

c)

It throws an InputMismatchException

d)

It returns -1

84.

How do you close a Scanner object in Java?

a)

scanner.close();

b)

close(scanner);

c)

Scanner.close();

d)

scanner.exit();

85.

What is the correct syntax to output "HelloWorld" in Java?

(a)