OOp Prelim Exam

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 33

Data type long literals are appended by _____

a.
Long

b.
Uppercase L 

c.
Both A and B

d.
Lowercase L
Feedback
Your answer is correct.

Question 2
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which type of function among the following shows polymorphism?

a.
Class member functions

b.
Inline function

c.
Virtual function

d.
Undefined functions
Feedback
Your answer is correct.

Question 3
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which among the following best defines single level inheritance?

a.
A class inheriting a nested class

b.
A class inheriting a derived class

c.
A class inheriting a base class

d.
A class which gets inherited by 2 classes
Feedback
Your answer is correct.

Question 4
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which statement transfers execution to different parts of your code based on the value of
an expression?
a.
Nested-if

b.
If

c.
Switch

d.
if-else-if
Feedback
Your answer is correct.

Question 5
Correct
Mark 1.00 out of 1.00

Flag question

Question text
The default value of a static integer  variable of a class in Java is,

a.
Garbage value

b.
1

c.
0

d.
Null
Feedback
Your answer is correct.

Question 6
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Who is known as the father of Java Programming Language?

a.
Charel Babbage

b.
Blais Pascal

c.
M. P Java

d.
James Gosling
Feedback
Your answer is correct.

Question 7
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which statement is not true in java language?

a.
A private member of a class cannot be accessed by the methods of the same class.

b.
A public member of a class can be accessed in all the packages.
c.
A protected member of a class can be accessed from its derived class.

d.
A private member of a class cannot be accessed from its derived class.
Feedback
Your answer is correct.

Question 8
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of these have highest precedence?

a.
*

b.
()

c.
>>

d.
++
Feedback
Your answer is correct.

Question 9
Incorrect
Mark 0.00 out of 1.00
Flag question

Question text
Consider the two methods (within the same class) public static int foo(int a, String s) { s =
"Yellow"; a=a+2; return a; } public static void bar() { int a=3; String s = "Blue"; a = foo(a,s);
System.out.println("a="+a+" s="+s); } public static void main(String args[]) { bar(); } What is
printed on execution of these methods?

a.
a = 5 s = Yellow

b.
a = 3 s = Blue

c.
a = 5 s = Blue

d.
a = 3 s = Yellow
Feedback
Your answer is incorrect.

Question 10
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which provides runtime environment for java byte code to be executed?

a.
JAVAC
b.
JRE

c.
JVM

d.
JDH
Feedback
Your answer is correct.

Question 11
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A constructor

a.
Must have the same name as the class it is declared within.

b.
(a), (b) and (c) above.

c.
May be declared private

d.
Is used to create objects.
Feedback
Your answer is correct.

Question 12
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Multiple inheritance means,

a.
one class inheriting from more super classes

b.
more classes inheriting from one super class

c.
None of the above

d.
more classes inheriting from more super classes
Feedback
Your answer is correct.

Question 13
Correct
Mark 1.00 out of 1.00

Flag question

Question text
In java control statements break, continue, return, try-catch-finally and assert belongs to?

a.
Loop Statements

b.
Pause Statement
c.
Selection statements

d.
Transfer statements
Feedback
Your answer is correct.

Question 14
Correct
Mark 1.00 out of 1.00

Flag question

Question text
In Java code, the line that begins with /* and ends with */ is known as?

a.
Both A & B

b.
Single line comment

c.
None of these

d.
Multiline comment
Feedback
Your answer is correct.

Question 15
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Which of the following are not Java modifiers?

a.
private

b.
friendly

c.
public

d.
transient
Feedback
Your answer is correct.

Question 16
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which among the following can’t be used for polymorphism?

a.
Predefined operator overloading

b.
Constructor overloading
c.
Static member functions

d.
Member functions overloading
Feedback
Your answer is correct.

Question 17
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What will be printed as the output of the following program? public class testincr { public
static void main(String args[]) { int i = 0; i = i++ + i; System.out.println("I = " +i); } }

a.
I=0

b.
I=1

c.
I=3

d.
I=2
Feedback
Your answer is correct.

Question 18
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Which of the following are not Java keywords ?

a.
double 

b.
then

c.
switch

d.
case
Feedback
Your answer is correct.

Question 19
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Java language was initially called as ________

a.
Oak

b.
J++
c.
Sumatra

d.
Pine
Feedback
Your answer is correct.

Question 20
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which programming language doesn’t support multiple inheritance?

a.
C++ and Java

b.
Java

c.
C and C++

d.
Java and SmallTalk
Feedback
Your answer is correct.

Question 21
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Which variables are created when an object is created with the use of the keyword 'new' and
destroyed when the object is  destroyed?

a.
Local variables

b.
Static variables

c.
Class Variables

d.
Instance variables
Feedback
Your answer is correct.

Question 22
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Among these expressions, which is(are) of type String?

a.
'0'

b.
"ab" + "cd"
c.
Both (A) and (B) above

d.
"0"
Feedback
Your answer is correct.

Question 23
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which polymorphism behavior do you see in below class?
class Paint {
// all methods have same name
public void Color(int x) {}

public void Color(int x, int y) {}

public void Color(int x, int y, int z) {}

a.
Constructor overloading

b.
Method overriding

c.
Run time polymorphism

d.
Method overloading
Feedback
Your answer is correct.

Question 24
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is the type and value of the following expression? (Notice the integer division) -4 +
1/2 + 2*-3 + 5.0

a.
double -5.0

b.
double -4.5

c.
int -5

d.
int -4
Feedback
Your answer is correct.

Question 25
Correct
Mark 1.00 out of 1.00

Flag question
Question text
Modulus operator (%) can be applied to which of these?

a.
Floating - point numbers

b.
Integers

c.
None of These

d.
Both A and B
Feedback
Your answer is correct.

Question 26
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following is TRUE?

a.
In java, an instance field declared public generates a compilation error.

b.
Instance variable names may only contain letters and digits.

c.
A class has always a constructor (possibly automatically supplied by the java compiler).

d.
int is the name of a class available in the package java.lang
Feedback
Your answer is correct.

Question 27
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is printed by the following statement? System.out.print("Hello,\nworld!");

a.
Hello, \nworld!

b.
"Hello, \nworld!"

c.
None of the above.

d.
Hello, world!
Feedback
Your answer is correct.

Question 28
Correct
Mark 1.00 out of 1.00

Flag question

Question text
To prevent any method from overriding, we declare the method as,

a.
static

b.
abstract

c.
const

d.
final
Feedback
Your answer is correct.

Question 29
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following could be written with little knowledge of java?

a.
Java Community Program

b.
Common Gateway Interface

c.
Java Servlets

d.
Java Server Pages
Feedback
Your answer is correct.

Question 30
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of these is returned by operator '&' ?

a.
Float

b.
Integer 

c.
Character

d.
Boolean
Feedback
Your answer is correct.

Question 31
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What do you call the languages that support classes but not polymorphism?

a.
Class based language

b.
Procedure Oriented language
c.
If classes are supported, polymorphism will always be supported

d.
Object-based language
Feedback
Your answer is correct.

Question 32
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which one of the following is not true?

a.
Abstract methods should be implemented in the derived class.

b.
An abstract class cannot have non-abstract methods.

c.
A class must be qualified as ‘abstract’ class, if it contains one abstract method.

d.
A class containing abstract methods is called an abstract class.
Feedback
Your answer is correct.

Question 33
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Consider the following class definition: public class MyClass { private int value; public void
setValue(int i){ /* code */ } // Other methods... } The method setValue assigns the value of i
to the instance field value. What could you write for the implementation of setValue?

a.
this.value = i;

b.
value == i;

c.
Both (A) and (B) and above

d.
value = i;
Feedback
Your answer is correct.

Question 34
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following is true?

a.
A finally block is executed whether an exception is thrown or not.

b.
A finally block is executed, only after the catch block is executed.

c.
A finally block is executed before the catch block but after the try block.

d.
A finally block is executed, only if an exception occurs.
Feedback
Your answer is correct.

Question 35
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Consider, public class MyClass { public MyClass(){/*code*/} // more code... } To instantiate
MyClass, you would write?

a.
MyClass mc = new MyClass;

b.
MyClass mc = new MyClass();

c.
MyClass mc = MyClass;

d.
MyClass mc = MyClass();
Feedback
Your answer is correct.

Question 36
Correct
Mark 1.00 out of 1.00
Flag question

Question text
In java control statements break, continue, return, try-catch-finally and assert belongs to?

a.
Selection statements

b.
Pause Statemen

c.
Loop Statements

d.
Transfer statements
Feedback
Your answer is correct.

Question 37
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which one is a template for creating different objects ?

a.
Interface

b.
Method
c.
A class

d.
An Array
Feedback
Your answer is correct.

Question 38
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Division operator has ____ precedence over multiplication operator

a.
Highest

b.
None of These

c.
Equal

d.
Least
Feedback
Your answer is correct.

Question 39
Correct
Mark 1.00 out of 1.00
Flag question

Question text
What is the output of the following program: public class testmeth { static int i = 1; public
static void main(String args[]) { System.out.println(i+” , “); m(i); System.out.println(i); } public
void m(int i) { i += 2; } }

a.
3,1

b.
1,1

c.
1,0

d.
1,3
Feedback
Your answer is correct.

Question 40
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is byte code in Java?

a.
Block of code written inside a class

b.
Code generated by a Java Virtual Machine

c.
Code generated by a Java compiler 

d.
Name of Java source code file
Feedback
Your answer is correct.

Question 41
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which one is true about a constructor ?

a.
A constructor may be declared private

b.
A constructor is used to create objects

c.
A constructor must have the same name as the class it is declared within

d.
All of the above
Feedback
Your answer is correct.

Question 42
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Which symbol is used to contain the values of automatically initialized arrays?

a.
Parentheses

b.
Braces

c.
Brackets Brackets

d.
Comma
Feedback
Your answer is correct.

Question 43
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which access type data gets derived as private member in derived class?

a.
Protected

b.
Public

c.
Protected and Private

d.
Private
Feedback
Your answer is correct.

Question 44
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is byte code in Java?

a.
Code generated by a Java compiler

b.
Block of code written inside a class

c.
Name of Java source code file

d.
Code generated by a Java Virtual Machine
Feedback
Your answer is correct.

Question 45
Correct
Mark 1.00 out of 1.00

Flag question
Question text
The fields in an interface are implicitly specified as,

a.
both static and final

b.
protected

c.
private

d.
static only
Feedback
Your answer is correct.

Question 46
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Consider the following code fragment Rectangle r1 = new Rectangle();
r1.setColor(Color.blue); Rectangle r2 = r1; r2.setColor(Color.red); After the above piece of
code is executed, what are the colors of r1 and r2 (in this order)?

a.
Color.blue Color.red

b.
Color.red Color.red

c.
Color.blue Color.blue

d.
Color.red Color.blue
Feedback
Your answer is correct.

Question 47
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following is not true?

a.
An interface can extend another interface.

b.
An interface can implement another interface.

c.
A class which is implementing an interface must implement all the methods of the interface.

d.
An interface is a solution for multiple inheritance in java.
Feedback
Your answer is correct.

Question 48
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of these is not a bitwise operator?
a.
&' Operator

b.
&=' Operator

c.
|=' Operator

d.
<=' Operator
Feedback
Your answer is correct.

Question 49
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following variable declaration would NOT compile in a java program?

a.
int 1_var;

b.
int var;

c.
int VAR;

d.
int var1;
Feedback
Your answer is correct.
Question 50
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is the full form of JVM ?

a.
Java Virtual Machine

b.
Java Very Small Machine

c.
Java Very Large Machine

d.
Java Verified Machine
Feedback
Your answer is correct.

You might also like