0% found this document useful (0 votes)
49 views

Ov Sample QB Oop in Java

This document contains a sample question paper for an exam on object-oriented programming in Java. It includes multiple choice questions divided into three categories: simple, average, and difficult. The questions test knowledge of Java concepts like exceptions, interfaces, generics, design patterns, and I/O streams.

Uploaded by

Heo Quay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Ov Sample QB Oop in Java

This document contains a sample question paper for an exam on object-oriented programming in Java. It includes multiple choice questions divided into three categories: simple, average, and difficult. The questions test knowledge of Java concepts like exceptions, interfaces, generics, design patterns, and I/O streams.

Uploaded by

Heo Quay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Sample Question Paper

QUESTION BANK
MODULE NAME: Object-oriented Programming in Java

Category - Simple

1) Fill in the blank with single option:


The ___________ block is executed even when an exception occurs.

a) try

b) catch

 c) finally

d) exception

2)
__________ is the inverse of throughput. That is, the percentage of total time spent in
garbage collection.

a) Pause time

b) Frequency of collection

c) Promptness

 d) Garbage collection overhead

3) ___________ interface is extended by the sub interfaces Set, List, and Queue.

a) Vector

 b) Collection

c) HashMap

d) Tree

4) ________ is not a method of the InputStream class.

Aptech Limited Page 1


Sample Question Paper

 a) repeat()

b) read()

c) close()

d) available()

5) __________ driver translates JDBC calls into database-specific calls or native calls.

a) ODBC-JDBC Bridge

b) JDBC Network-All Java

c) Native Protocol-All Java

 d) Native API-Java/Partly Java

Category - Average

1) Select the correct answer with multiple options:


Which of the following statements about Assertions are true?

 a) An assertion is a statement in Java that allows programmers to test their assumptions


about the program.

 b) Each assertion is composed of a boolean expression that is believed to be true when


the assertion executes.

c) Writing assertions while programming is one of the most difficult ways to detect and
correct errors in the code.

 d) The syntax of assertion statement is: assert <boolean_expression>;

Aptech Limited Page 2


Sample Question Paper

2) Select the correct answer with single option:

What will be the index of the string ‘bat’ when the expression ^bat$ is applied to it?

a)
Starting at index 1 and ending at index 3

b)
Starting at index 0 and ending at index 2

 c)
Starting at index 0 and ending at index 3

d)
Starting at index 1 and ending at index 2

3) Select the correct answer with single option:

Identify the correct code to create an instance of HashSet class.

a) HashSet<String>();

b) Set<String> words[] = new HashSet[];

c) HashSet<String> words = new Set<String>();

 d) Set<String> words = new HashSet<String>();

4) Select the correct answer with single option:

Which of the following statements about Generics are true?

a) Generics do not allow flexibility of dynamic binding.

b) The code reviews are difficult in Generics as the ambiguity is more between containers.

 c) In Generics, you cannot create generic constructors.

Aptech Limited Page 3


Sample Question Paper

 d) A local variable cannot be declared where the key and value types are different from each
other.

5) Match the following:

File Class Method Description


A) renameTo(File name) 1) Checks whether the file denoted by the pathname is a normal file.
B) exists() 2) Converts the abstract pathname into a pathname string.
C) getPath() 3) Tests the existence of file or directory.
D) isFile() 4) Name the existing File object with the new name.

 a) A-4, B-3, C-2, D-1

b) A-2, B-1, C-4, D-3

c) A-1, B-2, C-3, D-4

d) A-3, B-2, C-4, D-1

Category – Difficult

1) Select the correct answer with single option:

Identify the correct code to create a locale for the country Canada for the French language.

a) caLocale = new Locale(“fr”,”Canada”);

b) caLocale = new Locale(“french”,”CA”);

 c) caLocale = new Locale(“fr”,”CA”);

d) caLocale = new Locale(“french”,”Canada”);

2) Select the correct answer with multiple options:

Which of the following statements about Design Patterns are true?

Aptech Limited Page 4


Sample Question Paper

 a) A design pattern is a clearly defined solution to problems that occur frequently.

 b) Design patterns are based on the fundamental principles of object oriented design.

 c) A design pattern is not an implementation, nor is it a framework.

d) The use of design patterns results in decreased code maintainability.

3) Select the correct answer with single option:

Identify the correct code to update a record from a RowSet object.

a) jdbcRs.relative(2);
jdbcRs.updateFloat(“RATE”, 14.00f);
jdbcRs.updateRow();

b) jdbcRs.updateFloat(“RATE”, 14.00f);
jdbcRs.absolute(2);
jdbcRs.updateRow();

c) jdbcRs.absolute(3);
jdbcRs.updateFloat(“RATE”, 14.00f);
jdbcRs.update();

 d) jdbcRs.absolute(3);
jdbcRs.updateFloat(“RATE”, 14.00f);
jdbcRs.updateRow();

4) Select the correct answer with multiple options:


Identify the situations responsible for race conditions in a program.

a) A thread holding multiple resources required by another thread.

 b) Two or more threads share the same data between them.

 c) Two or more threads try to read and write the shared data simultaneously.

d) Threads waiting for each other to release resources acquired by them.

Aptech Limited Page 5


Sample Question Paper

5) Select the correct answer with single option:

Identify the correct code for using the BufferedInputStream class.

 a) . . .
String temp = “Welcome to the world of Java”;
byte [] bufObj = temp.getBytes();
ByteArrayInputStream fileObj = new
ByteArraInputStream(bufObj);
BufferedInputStream inObj = new BufferredInputStream(fileObj);
. . .

b) . . .
String temp = “Welcome to the world of Java”;
ByteArrayInputStream fileObj = new ByteArraInputStream();
byte [] bufObj = temp.getBytes();
BufferedInputStream inObj = new BufferredInputStream(bufObj);
. . .

c) . . .
String temp = “Welcome to the world of Java”;
byte [] bufObj = temp.getBytes();
BufferedInputStream inObj = new BufferredInputStream(bufObj);
ByteArrayInputStream fileObj = new
ByteArraInputStream(fileObj);

. . .

d) . . .
String temp = “Welcome to the world of Java”;
byte [] bufObj = getBytes(temp);
ByteArrayInputStream fileObj = new
ByteArraInputStream(bufObj);
BufferedInputStream inObj = new BufferredInputStream(fileObj);
. . .

Aptech Limited Page 6

You might also like