Java Programming Questions and Answers Set 8

Java Programming OOPs

Questions 71 to 80



71.
What is garbage collection in the context of Java?
(a)   The operating system periodically deletes all of the java files available on the system.
(b)   Any package imported in a program and not used is automatically deleted.
(c)   When all references to an object are gone, the memory used by the object is automatically reclaimed.
(d)   The JVM checks the output of any Java program and deletes anything that doesn't make sense.
(e)   When all references to an object are gone the memory used by the object is not reclaimed.
72.
The concept of multiple inheritance is implemented in Java by
I.     Extending two or more classes.
II.     Extending one class and implementing one or more interfaces.
III.    Implementing two or more interfaces.

(a)   Only (II)                                           (b) (I) and (II)                       (c) (II) and (III)
(d)   Only (I)                                            (e)  Only (III).
73.
In Java, declaring a class abstract is useful
(a)   To prevent developers from further extending the class
(b)   When it doesn't make sense to have objects of that class
(c)   When default implementations of some methods are not desirable
(d)   To force developers to extend the class not to use its capabilities
(e)   When it makes sense to have objects of that class.
74.
What is the error in the following class definitions?
          Abstract class xy
           { 
              abstract sum (int x, int y) {       }
           }
(a)   Class header is not defined properly.
(b)   Constructor is not defined.
(c)   Method is not defined properly
(d)   Method is defined properly
(e)   No error.
75.
Which of these field declarations are legal within the body of an interface?
(a)   Private final static int answer = 42    (b) public static int answer=42
(c)   final static answer =42                     (d) int answer
(e)   No error.
76.
A package is a collection of
(a)   Classes                                          (b) Interfaces           (c) Editing tools
(d)   Classes and interfaces                    (e) Editing tools and interfaces.
77.
A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?
(a)   Declare the method with the keyword public
(b)   Declare the method with the keyword private
(c)   Declare the method with the keyword protected
(d)   Do not declare the method with any accessibility modifiers
(e)   Declare the method with the keyword public and private.
78.
Basic Java language functions are stored in which of the following java package?
(a)   java.lang           (b) java.io                (c) java.net              (d) java.util              (e) java.awt.
79.
Which of the following is a member of the java.lang package?
(a)   List                   (b) Queue                (c) Math                  (d) Stack                 (e) Process.
80.
Which of the following has a method names flush( )?
(a)   Input stream                                    (b) Output Stream
(c)   Reader stream                                 (d) Input reader stream
(e)   Input output stream.




Answers



71.
Answer : (c)
Reason : As the remaining all contradict the functionality of JVM.
72.
Answer : (c)
Reason : The remaning are not opt solutions for the concept of multiple inheritance.
73.
Answer : (b)
Reason : As other Choices are contradicting the meaning of Abstract Class .
74.
Answer : (c)
Reason : method is not defined properly.
75.
Answer : (b)
Reason : The remaining are all illegal.
76.
Answer : (d)
Reason : Editing tools are not the part of packages.So d is the correct Answer.
77.
Answer : (d)
Reason : The desired accessibility is package accessibility, which is the default accessibility for members that have no accessibility modifier. Package is not an accessibility modifier.
78.
Answer : (a)
Reason : The basic language functions are stored in a package inside of the java package called java.lang.
79.
Answer : (b)
Reason : Math is  a member of the java.lang package whereas the remaining are not.
80.
Answer : (b)
Reason : Output stream has the method flush ( ) that flushes the output stream.



<< Prev   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22  

 23   24   25   26   27   28   29   30  Next >>


2 comments :

  1. Q.79, Answer : (b)
    Reason : Math is a member of the java.lang package whereas the remaining are not.
    But in the question. The "Math" is "c", so why the answer is "b" then?

    ReplyDelete
  2. This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

    Love from

    ReplyDelete