1. Which of the following is
the functionality of ‘Data Abstraction’?
a) Reduce Complexity
b) Binds together code and
data
c) Parallelism
d) None of the mentioned
View Answer
Answer: a
Explanation: An essential
element of Object Oriented Programming is ‘Data Abstraction’ which means hiding
things. Complexity is managed through abstraction.
2. Which of the following
mechanisms is/are provided by Object Oriented Language to implement Object
Oriented Model?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
3. Which of the these is the
functionality of ‘Encapsulation’?
a) Binds together code and
data
b) Using single interface
for general class of actions.
c) Reduce Complexity
d) All of the mentioned
View Answer
Answer: a
Explanation: ‘Encapsulation’
acts as protective wrapper that prevents code and data from being accessed by
other code defined outside the wrapper.
4. What is ‘Basis of
Encapsulation’?
a) object
b) class
c) method
d) all of the mentioned
View Answer
Answer: d
Explanation: Encapsulation
is the mechanism that binds together code and data it manipulates, and keeps
both safe from outside interface and misuse. Class, which contains data members
and methods is used to implement Encapsulation.
5. How will a class protect
the code inside it?
a) Using Access specifiers
b) Abstraction
c) Use of Inheritance
d) All of the mentioned
View Answer
Answer: a
Explanation: Each method or
variable in a class may be marked ‘public’ or ‘private’. They are called Access
Specifiers.
6. What is the output of
this program?
class Test {
int a;
public int b;
private int c;
}
class AcessTest {
public static void main(String args[])
{
Test ob = new Test();
ob.a = 10;
ob.b = 20;
ob.c = 30;
System.out.println(" Output :a,
b, and c" + ob.a + " " + ob.b + " " + ob.c);
}
}
a) Compilation error
b) Run time error
c) Output : a, b and c 10 20
30
d) None of the mentioned
View Answer
Answer: a
Explanation: Private members
of a class cannot be accessed directly. In the above program, the variable c is
a private member of class ‘Test’ and can only be accessed through its methods.
7. Which of the following is
a mechanism by which object acquires the properties of another object?
a) Encapsulation
b) Abstraction
c) Inheritance
d) Polymorphism
View Answer
Answer: c
Explanation: ‘Inheritance’
is the mechanism provided by Object Oriented Language, which helps an object to
acquire the properties of another object usually child object from parent
object.
8. Which of the following
supports the concept of hierarchical classification?
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
View Answer
Answer: d
Explanation: Use of
Hierarchical classification avoids defining the properities of object
explicitly at each level which have acquired their properties from higher
levels.
9. Which Keyword from the
following is used to inherit properties from one class into another?
a) extends
b) subclasses
c) native
d) all of the mentioned
View Answer
Answer: a
Explanation: None.
10. Which of the following
concept is often expressed by the phrase, ‘One interface, multiple methods’?
a) Abstraction
b) Polymorphism
c) Inheritance
d) Encapsulation
View Answer
Answer: b
Explanation: None.
-----------------------------------------------------------------------------------------------------------------------
1. Which of these is a valid
keyword in Java?
a) interface
b) string
c) float
d) unsigned
View Answer
Answer: a
Explanation: “String” and
“Float” are class types in Java. “unsigned” is a keyword used in C/C++ but not
in Java.
2. Which of these is a
reserved word in Java Programming Language?
a) method
b) native
c) subclasses
d) reference
View Answer
Answer: b
Explanation: “native” is a
valid keyword used to modify method declaration. The valid keyword used in Java
language for subclassing is “extends” not subclasses.
3. How many reserved
keywords are there in Java language?
a) 50
b) 52
c) 49
d) 45
View Answer
Answer: a
Explanation: As of Java 1.5
there are 50 keywords out of which 48 are used(const and goto keywords are
unusable keywords).
4. Which of the following is
a Literal Representation?
a) 100
b) ‘100’
c) Sample
d) None of the mentioned
View Answer
Answer: a
Explanation: A constant
value in Java is created by using a ‘Literal Representation’ of it. Integer
Literals are not enclosed in quotes where as String Literals are enclosed in
quotes.
5. What are the types of
comments defined by Java?
a) Single-line comment
b) Multi-line comment
c) Documentation comment
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
6. Which of the following is
readable by both Computer and Human?
a) Single-line comment
b) Multi-line comment
c) Documentation comment
d) All of the mentioned
View Answer
Answer: c
Explanation: Documentation
comment is used to produce an HTML file that documents the given program.
7. Which of the following
‘Seperator’ is most commonly used in Java program?
a) Parenthesis
b) Braces
c) Comma
d) Semicolon
View Answer
Answer: d
Explanation: Semicolon is
most commonly used in Java program, which terminates statements.
8. Which of the following is
used to name class, method and variables?
a) Identifiers
b) Keywords
c) Both
d) None of the mentioned
View Answer
Answer: a
Explanation: Identifiers are
used to name classes, methods and variables.
9. ‘Whitespace’ in Java
language may be?
a) A space
b) A new line
c) A tab
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
10. Which of the following
is the output of the program?
class Test {
public static void main(String args[])
{
int num = 10;
System.out.println("The value of
num is" +NUM);
}
}
a) Compilation error
b) Run time error
c) Exception
d) The value of num is 10
View Answer
Answer: a
Explanation: Java is
case-sensitive. Identifier which is used to name variable and print are
different.
---------------------------------------------------------------------------------------------------------------------------