wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS8392 - Object Oriented Programming - Unit 1

Total questions: 63

Worksheet time: 36mins

Name
Class
Date
1.

A programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

2.

(from Greek meaning “many forms”) is the quality that allows one interface to access a general class of actions.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

3.

Is the process by which one object can acquire the properties of another object.

a)

Polymorphism

b)

Inheritance

c)

Encapsulation

d)

Object-Oriented Programming

4.

Select all the given characteristic of OOP

a)

Data structures are designed such that they characterize the objects.

b)

C input/output is based on library and the processes are carried out by including functions.

c)

Programs are divided into what are known as objects.

d)

Emphasis is on data rather than procedure

5.

C++ is procedure oriented programming & C is object oriented programming.

a)

True

b)

False

c)

Trulse

d)

I don't know

6.

Which of the following option leads to the portability and security of Java?

a)

Bytecode is executed by JVM

b)

The applet makes the Java code secure and portable

c)

Use of exception handling

d)

Dynamic binding between objects

7.

Where an object of a class get stored?

a)

Heap

b)

Stack

c)

Disk

d)

File

8.

Java uses two stage system for program execution. They are

a)

Compiler and instruction

b)

Compiler and interpreter

c)

Copy and compiler

d)

None

9.

Garbage collection in Java is

a)

Unused package in a program automatically gets deleted.

b)

Memory occupied by objects with no reference is automatically reclaimed for deletion.

c)

Java deletes all unused java files on the system.

d)

The JVM cleans output of Java program.

10.

Java compiled source code programs have extension

a)

.java

b)

. source

c)

.class

d)

. compile

11.

Which of the following is smallest integer data type ?

a)

long

b)

int

c)

byte

d)

short

12.

Byte variables are declared by use of the ____________ keyword (Using Primitive Data Type).

a)

byte

b)

Byte

c)

Bytes

d)

bytes

13.

Default value of character data type in Java Programming is ___________________.

a)

null

b)

undefine

c)

0

d)

"\u0000'

14.

________ is wrapping of data into a single unit called class.

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

15.

__________ refers to the act of representing essential details.

a)

Polymorphism

b)

Abstraction

c)

Inheritance

d)

Encapsulation

16.

__________ is the process in which objects of one class can link and share some common properties from the objects of another class.

a)

Abstraction

b)

Inheritance

c)

Polymorphism

d)

Encapsulation

17.

__________ is the process of using a function for more than one purpose. It allows the use of different internal structures of the object by keeping the same external interface.

a)

Inheritance

b)

Polymorphism

c)

Abstraction

d)

Encapsulation

18.

In this process the function call is linked to the function signature at runtime.

a)

Dynamic Binding

b)

Static Binding

19.

This is the logical link from caller program to the function and is established by using function name in the caller program

a)

Dynamic Binding

b)

Static Binding

20.

Choose Object oriented programming languages from the following.

a)

C

b)

Java

c)

BASIC

d)

Small Talk

21.

Which of the following adopts top down approach?

a)

Object Oriented Programming

b)

Procedural Programming

22.

An _________ is an instance or of a copy of a class.

a)

Class

b)

Object

c)

Attribute

23.

A ________ is blue print that defines certain characteristics and behavior. It is simply a representation of different types of objects.

a)

Class

b)

Object

c)

Attribute

d)

Characteristics

24.

Which of this keyword must be used to inherit a class?

a)

super

b)

this

c)

extends

d)

extent

25.

A class member declared protected becomes a member of subclass of which type?

a)

public member

b)

private member

c)

protected member

d)

static member

26.

class A

{

int i;

void display()

{

System.out.println(i);

}

}

class B extends A

{

int j;

void display()

{

System.out.println(j);

}

}

class inheritance_demo

{

public static void main(String args[])

{

B obj = new B();

obj.i=1;

obj.j=2;

obj.display();

}

}

a)

0

b)

1

c)

2

d)

Compilation Error

27.

What will be the output of the following Java program?

class A

{

int i;

}

class B extends A

{

int j;

void display()

{

super.i = j + 1;

System.out.println(j + " " + i);

}

}

class inheritance

{

public static void main(String args[])

{

B obj = new B();

obj.i=1;

obj.j=2;

obj.display();

}

}

a)

2 2

b)

3 3

c)

2 3

d)

3 2

28.

Using which of the following, multiple inheritance in Java can be implemented?

a)

Interfaces

b)

Multithreading

c)

Protected methods

d)

Private methods

29.

If super class and subclass have same variable name, which keyword should be used to use super class?

a)

super

b)

this

c)

upper

d)

classname

30.

In order to restrict a variable of a class from inheriting to subclass, how variable should be declared?

a)

Protected

b)

Private

c)

Public

d)

Static

31.

If class B is subclassed from class A then which is the correct syntax

a)

class B:A{}

b)

class B extends A{}

c)

class B extends class A{}

d)

class B implements A{}

32.

Which inheritance in java programming is not supported

a)

Multiple inheritance using classes

b)

Multiple inheritance using interfaces

c)

Multilevel inheritance

d)

Single inheritance

33.

Order of execution of constructors in Java Inheritance is

a)

Base to derived class

b)

Derived to base class

c)

Random order

d)

none

34.

Attributes of an object are also known as

a)

methods

b)

properties

c)

classes

d)

functions

35.

Programming statements written in a high-level programming language are called ____.

a)

Byte Code

b)

Source Code

c)

executable code

d)

destination code

36.

Which of the following is not a primitive data type of JAVA?

a)

int

b)

char

c)

String

d)

float

37.

Java is a platform independent programming language because

a)

It is written almost similar to English language

b)

Java compiler translates the source code directly to the machine level language.

c)

It follows the concept of “write once and compile everywhere”.

d)

It compiles to an intermediate code targeting a virtual machine, which can be interpreted by an interpreter for a given OS.

38.

Which of the following features are not common in both java and c++?

a)

The class declaration

b)

The access modifiers

c)

The Encapsulation of data and methods

d)

multiple inheritance from class

39.

What is the output of following program?

class incr

{

public static void main(String args[])

{

int i=3;

System.out.println( ++i * 5);

}

}

(a)  

40.

Which of the following can not be used as correct variable name(identifier) in JAVA?

a)

malloc

b)

final

c)

calloc

d)

string

41.

Attributes of an object are also known as

a)

methods

b)

properties

c)

classes

d)

functions

42.
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
43.

+ getEndDate

+ setOverdraft


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

44.

+ getAccountNumber

+ addInterest


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

45.

Mortgage, Current and Account


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

46.

You can make changes to an object with

a)

methods

b)

attributes

c)

modifiers

d)

parameters

47.

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

48.

Which of the following is the correct main() method signature in Java?

a)

public static void main (String [] args)

b)

public static void Main (String [] args)

c)

public static void main (string [] args)

d)

public static void main (String args)

49.

Which of the following is a comment in the Java language?

a)

/ comment /

b)

//comment

c)

/ comment */

d)

<-- comment -->

50.

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

a)

int 1myInteger = 0;

b)

int int = 0;

c)

Int my Integer = 0;

d)

int myInteger = 0;

51.

Which of this command does not have errors?

a)

System.out.print("Hello World")

b)

System.out.print(Hello World);

c)

System.out.Print("Hello World);

d)

System.out.print("Hello World");

52.

What will be output of below program?

public class Test {

public static void main(String[] args) {

int x = 10*20-20;

System.out.println(x);

}

}

a)

Runtime Error

b)

Prints 180

c)

Prints 0

d)

None of the above

53.

What is the output for the following statement:

System.out.print("1"+"1");

a)

11

b)

2

c)

Error Message

54.

Indicate the actual output of the statements below:

int thisYear = 2020;

System.out.println("The current year is "+thisYear);

a)

The current year is thisYear

b)

The current year is 2020

c)

No output; an error exists

d)

The current year is

55.

Which of the following is used as a terminator in Java programming?

a)

)

b)

;

c)

.

d)

>

56.

What is the problem with this code?

Line 1: String myName = "Mary Jacobson";

Line 2: System.out.println ("My name is " + myname);

a)

Line 2: should be System.out.println ("My name is myName");

b)

Line 2: should be System.out.println ("My name is "+ myName);

c)

Line 2: should be System.out.display("My name is " + myname);

d)

There is no problem with the code

57.

int x= 10;

int y = 20;

int z = x + y;

System.out.println(z);

Guess the output.

a)

1020

b)

10 20

c)

30

d)

"10 20"

58.

What is the job of a Java class's fields?

a)

Used for communication with an object of this class type

b)

Used for calculations when an object is constructed

c)

Allows for import statements in this class

d)

Store the state of an object of this class type

59.

How many constructors does this Java class have?

a)

0

b)

1

c)

2

d)

3

60.

What is the return type of Constructors?

a)

int

b)

float

c)

void

d)

none of the mentioned

61.

Which of this statement is incorrect?

a)

All object of a class are allotted memory for the all the variables defined in the class

b)

If a function is defined public it can be accessed by object of other class by inheritance.

c)

main() method must be made public

d)

All object of a class are allotted memory for the methods defined in the class

62.

Write method header to Return a square root of a number

a)

public static void double sqrt(value)

b)

public static void double sqrt(double value)

c)

public static double sqrt(value)

d)

public static double sqrt(double value)

63.

The body of a method definition is contained within a set of ______________.

a)

parentheses

b)

rectangle brackets

c)

curly braces

d)

angle brackets