Object Oriented Programming Mid - I, February - 2012

1.Which of the following statement about the java language is true?
  • Both procedural and OOP are supported in java
  • Java supports only procedural approach through programming
  • Java supports only OOP approach
  • None of the above
Answer: A
2.Which of the following statements is false about objects?
  • An instance of a class is an object
  • Objects can access both static and instance data
  • Object is the superclass of all other classes
  • Object do not permit encapsulation
Answer: B
3.Which method can access to private attributes of a class?
  • Only static method of the same class
  • Only instances of the same class
  • Only methods those defined in the same class
  • Only classes available in the same package
Answer: B
4.What is the value of ‘number’ after the following code fragment execution?
int number = 0;
int number2 = 12
while (number < number2)
{
number = number 1;
}
  • 5
  • 12
  • 21
  • 13
Answer: B
5.Which can be passed as an argument to a function?
  • Constant
  • Expression
  • Other function
  • All the above
Answer: A
6.“this” pointer
  • Implicitly points to an object
  • Can be explicitly used in class
  • Can be used to return an object
  • All the above
Answer: D
7.A static function
  • Should be called when an object is destroyed
  • Is closely connected with individual objects of a class
  • Can be called using the class name and function name
  • Is used when a dummy object must be created
Answer: C
8.The new operator
  • Returns a pointer to the variable
  • Creates a variable called new
  • Obtains memory for a new variable
  • Tells how much memory is available
Answer: C
10.Which of the following statements are true? [ ]
A)An abstract class may not have any final methods.
B)A final class may not have any abstract methods.
C)An inner class may be declared with any accessibility keyword.
D)Transient variables must be static.
  • B&C
  • A
  • A&C
  • D
Answer: A
11._______________ is a technical definition of the language that includes the syntax and semantics.
Answer: Java language specification
12.________________ can be characterized as data controlling access to code.
Answer: Object oriented programming
13.__________________ is a software unit that combines a structured set of data with a set of operations for
inspecting and manipulating that data.
Answer: Object
14._______________ is used to convert the one type value to another.
Answer: Casting
15._______________ method cannot be overridden.
Answer: Final
16.___________________modifier can be accessed only to classes in the same package.
Answer: Default modifier
17.___________________ modifiers applies to variables only and it is not stored as part of its objects persistent
state.
Answer: Transient
18._________________ package has the ability to analyze itself at runtime.
Answer: Java.lang.reflect
19.A ________________ is a collection of classes and interfaces that provides a high-level layer of access
protection and name space management.
Answer: Package
20.Interfaces with no methods are called as _____________________
Answer: Marker interface