java-mcqs - Set (3)

Correct Answer: Orange && Worng Answer: Red

1. The process that focuses on only important characteristics is known as:

  • (A). Encapsulation
  • (B). Polymorphism
  • (C). Abstraction
  • (D). Inheritance
  • View Answer

    Explanation: The insulation of data from direct access by the program is called as the data abstraction.Data abstraction also called as data hiding, is the mechanism where by the code and the data it manipulates are wrapped into a single unit.

    2. Which statement is true regarding an object: –

  • (A). An object is of a class
  • (B). An object is an instance of a class
  • (C). An object is a variable
  • (D). An object is not an instance of class
  • View Answer

    Explanation: An object is an instance of class.

    3. An object-oriented programming composition relates to

  • (A). The use of consistent coding convection
  • (B). In refers to coherent, common, behavior
  • (C). It refers to polymorphic behavior
  • (D). None of these
  • View Answer

    Explanation: Composition is about an object that is made up of other objects, referred as “containment. Composition implies that the life cycles are more strongly linked, that means Whole is responsible for the life time of Part.

    4. In object-oriented programming a new classes can be defined by extending existing classes

  • (A). Encapsulation
  • (B). Interface
  • (C). Composition
  • (D). Inheritance
  • View Answer

    Explanation: Inheritance is a mechanism that enables one class to inherit all of the behaviour (methods ) and attributes (instance variables) of another class.

    5. Give a class name Book, which one of these is a valid constructor declaration for the class:

  • (A). Book (Book b) {}
  • (B). Book Book ()
  • (C). Final Book ()
  • (D). Abstract Book ()
  • View Answer

    Explanation: A constructor cannot specify any return type, not even void. A constructor cannot be final, static or abstract.

    6. The wrapping of data and functions into a sigh unit is called

  • (A). Encapsulation
  • (B). Abstraction
  • (C). Date hiding
  • (D). Polymorphism
  • View Answer

    Explanation: Not Avilable

    7. Polymorphism is a characteristic of:

  • (A). JAVA language
  • (B). C language
  • (C). Cobol language
  • (D). None of the above
  • View Answer

    Explanation: Java is object-oriented programming and Polymorphism is a features fo OOPs.

    8. The numerical range of a char data type in Java:

  • (A). -128 to 127
  • (B). 0 to 256
  • (C). 0 to 32767
  • (D). 0 to 65535
  • View Answer

    Explanation: Not Avilable

    9. Which of the following events will cause a thread to die? i.e. called

  • (A). The method sleep () is called
  • (B). The method wait () is called
  • (C). The execution of the start () is called
  • (D). Execution of run () method ends is called
  • View Answer

    Explanation: A thread dies when the execution of the run( ) method ends.

    10. Which of the following method is true regarding finalize ()

  • (A). It must be only declared with protected accessibility
  • (B). Finalize () method can be overloaded
  • (C). Finalize () method cannot be overloaded
  • (D). All of the above are true
  • View Answer

    Explanation: Not Avilable

    11. Which of the following is valid method for declaration in Java:

  • (A). void method2
  • (B). int 1 method1
  • (C). int method3 () void
  • (D). void method ()
  • View Answer

    Explanation: Methods must specify a return type or are declared void.

    12. The concept of multiple interface implementations in Java by:

  • (A). Extending two or more classes
  • (B). Extending one class and implementing one or more interface
  • (C). Implementing inheritance
  • (D). Implementing thread
  • View Answer

    Explanation: Not Avilable

    13. File class is included in which package.

  • (A). java.io.package
  • (B). java.lng.package
  • (C). java.awt.package
  • (D). java.util.package
  • View Answer

    Explanation: Java File class is a part of java.io package.

    14. What is the sequence of major events in the life cycle of an applet:

  • (A). init, start, stop, destroy
  • (B). start, init, stop, destroy
  • (C). init, start, destroy
  • (D). init, destroy, stop
  • View Answer

    Explanation: Applet life cycle has 5 methods init(), start(), stop(), aint() and destroy().

    15. Threading provides execution of:

  • (A). Only one module of the program at a time
  • (B). Only two modules of the program at a time
  • (C). All related program sub blocks executes simultaneous
  • (D). None of the above
  • View Answer

    Explanation: The process of executing multiple threads simultaneously is known as multithreading.