Oop PrlmExam

You might also like

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.
Lowercase L

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

Question 2
Correct
Mark 1.00 out of 1.00

Flag question

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

a.
abstract

b.
final

c.
const

d.
static
Feedback
Your answer is correct.

Question 3
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 4
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Division operator has ____ precedence over multiplication operator
a.
Equal

b.
None of These

c.
Least

d.
Highest
Feedback
Your answer is correct.

Question 5
Correct
Mark 1.00 out of 1.00

Flag question

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

a.
private

b.
static only

c.
protected

d.
both static and final
Feedback
Your answer is correct.
Question 6
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
What is byte code in Java?

a.
Code generated by a Java compiler

b.
Name of Java source code file

c.
Code generated by a Java Virtual Machine

d.
Block of code written inside a class
Feedback
Your answer is incorrect.

Question 7
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Java language was initially called as ________

a.
Sumatra
b.
Pine

c.
J++

d.
Oak
Feedback
Your answer is correct.

Question 8
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 9
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,0

c.
1,1

d.
1,3
Feedback
Your answer is correct.

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.
JDH

b.
JAVAC

c.
JVM

d.
JRE
Feedback
Your answer is correct.

Question 11
Incorrect
Mark 0.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 incorrect.

Question 12
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 13
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which statement is not true in java language?

a.
A public member of a class can be accessed in all the packages.

b.
A private member of a class cannot be accessed from its derived class.
c.
A private member of a class cannot be accessed by the methods of the same class.

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

Question 14
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.
Null

c.
0

d.
1
Feedback
Your answer is correct.

Question 15
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 VAR;

b.
int var;

c.
int var1;

d.
int 1_var;
Feedback
Your answer is correct.

Question 16
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following are not Java keywords ?

a.
double 

b.
switch

c.
then

d.
case
Feedback
Your answer is correct.

Question 17
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 18
Correct
Mark 1.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 = 5 s = Blue

c.
a = 3 s = Yellow

d.
a = 3 s = Blue
Feedback
Your answer is correct.

Question 19
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.red Color.red

b.
Color.blue Color.blue

c.
Color.blue Color.red

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

Question 20
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.
Instance variables

b.
Static variables

c.
Class Variables

d.
Local variables
Feedback
Your answer is correct.

Question 21
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.
int -4

b.
double -5.0

c.
int -5

d.
double -4.5
Feedback
Your answer is correct.

Question 22
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Multiple inheritance means,

a.
more classes inheriting from more super classes

b.
None of the above

c.
more classes inheriting from one super class

d.
one class inheriting from more super classes
Feedback
Your answer is incorrect.

Question 23
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.
None of the above.

b.
Hello, world!

c.
"Hello, \nworld!"

d.
Hello, \nworld!
Feedback
Your answer is correct.

Question 24
Correct
Mark 1.00 out of 1.00

Flag question

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

a.
Boolean

b.
Character
c.
Integer 

d.
Float
Feedback
Your answer is correct.

Question 25
Correct
Mark 1.00 out of 1.00

Flag question

Question text
A constructor

a.
May be declared private

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

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

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

Question 26
Incorrect
Mark 0.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.
value == i;

b.
this.value = i;

c.
value = i;

d.
Both (A) and (B) and above
Feedback
Your answer is incorrect.

Question 27
Correct
Mark 1.00 out of 1.00

Flag question

Question text
What is the full form of JVM ?

a.
Java Verified Machine

b.
Java Virtual Machine

c.
Java Very Large Machine
d.
Java Very Small Machine
Feedback
Your answer is correct.

Question 28
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.
Single line comment

b.
Multiline comment

c.
Both A & B

d.
None of these
Feedback
Your answer is correct.

Question 29
Correct
Mark 1.00 out of 1.00

Flag question

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

b.
An Array

c.
A class

d.
Interface
Feedback
Your answer is correct.

Question 30
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.
Transfer statements

d.
Loop Statements
Feedback
Your answer is correct.
Question 31
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following is TRUE?

a.
int is the name of a class available in the package java.lang

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

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

d.
Instance variable names may only contain letters and digits.
Feedback
Your answer is correct.

Question 32
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.
if-else-if

d.
Switch
Feedback
Your answer is correct.

Question 33
Incorrect
Mark 0.00 out of 1.00

Flag question

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

a.
'0'

b.
"0"

c.
Both (A) and (B) above

d.
"ab" + "cd"
Feedback
Your answer is incorrect.

Question 34
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.
Brackets Brackets

b.
Parentheses

c.
Comma

d.
Braces
Feedback
Your answer is correct.

Question 35
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which one is true about a constructor ?

a.
A constructor is used to create objects

b.
All of the above
c.
A constructor may be declared private

d.
A constructor must have the same name as the class it is declared within
Feedback
Your answer is correct.

Question 36
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which one of the following is not true?

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

b.
A class containing abstract methods is called an abstract class.

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

d.
A class must be qualified as ‘abstract’ class, if it contains one abstract method.
Feedback
Your answer is correct.

Question 37
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.
Member functions overloading

c.
Constructor overloading

d.
Static member functions
Feedback
Your answer is correct.

Question 38
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 = MyClass();

b.
MyClass mc = new MyClass();
c.
MyClass mc = MyClass;

d.
MyClass mc = new MyClass;
Feedback
Your answer is correct.

Question 39
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 Servlets

b.
Java Server Pages

c.
Common Gateway Interface

d.
Java Community Program
Feedback
Your answer is correct.

Question 40
Correct
Mark 1.00 out of 1.00
Flag question

Question text
Which of the following is not true?

a.
An interface can implement another interface.

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

c.
An interface is a solution for multiple inheritance in java.

d.
An interface can extend another interface.
Feedback
Your answer is correct.

Question 41
Correct
Mark 1.00 out of 1.00

Flag question

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

a.
A class which gets inherited by 2 classes

b.
A class inheriting a derived class
c.
A class inheriting a base class

d.
A class inheriting a nested class
Feedback
Your answer is correct.

Question 42
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=2

d.
I=3
Feedback
Your answer is correct.

Question 43
Correct
Mark 1.00 out of 1.00
Flag question

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

a.
C and C++

b.
C++ and Java

c.
Java and SmallTalk

d.
Java
Feedback
Your answer is correct.

Question 44
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
What is byte code in Java?

a.
Code generated by a Java compiler 

b.
Name of Java source code file
c.
Block of code written inside a class

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

Question 45
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.
Method overloading

b.
Method overriding

c.
Constructor overloading
d.
Run time polymorphism
Feedback
Your answer is correct.

Question 46
Incorrect
Mark 0.00 out of 1.00

Flag question

Question text
Which of the following is true?

a.
A finally block is executed, only if an exception occurs.

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 whether an exception is thrown or not.
Feedback
Your answer is incorrect.

Question 47
Correct
Mark 1.00 out of 1.00

Flag question

Question text
Which of the following are not Java modifiers?

a.
friendly

b.
private

c.
public

d.
transient
Feedback
Your answer is correct.

Question 48
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.
Transfer statements

c.
Loop Statements

d.
Pause Statement
Feedback
Your answer is correct.

Question 49
Correct
Mark 1.00 out of 1.00

Flag question

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

a.
James Gosling

b.
Charel Babbage

c.
M. P Java

d.
Blais Pascal
Feedback
Your answer is correct.

Question 50
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.
Private

b.
Protected

c.
Public

d.
Protected and Private
Feedback
Your answer is correct.

You might also like