Java Programming OOP Questions and Answers Set 6

Java Programming OOPs

Questions 51 to 60



51.
Re-implementing an inherited method in a sub class to perform a different task from the parent class is called
(a)  Binding             (b)  Transferring       (c)  Hiding               (d)  Coupling           (e)  extending.
52.
In a class definition, the special method provided to be called to create an instance of that class is known as a/an
(a)  Interpreter          (b)  Destructor         (c)  Constructor       (d)  Object              (e)  Compiler.
53.
Consider the following statements about Java packages:
I.     Packages don’t provide a mechanism to partition all class names into more manageable chunks.
II.     Packages provide a visibility control mechanism.
III.    One of the important properties of a package is that all classes defined inside a package is accessible by code outside that package.
IV.   The .class files for classes declared to be part of a package can be stored in multiple directories.
Which of them is correct?
(a)  Only (I) above                                  (b)  Only (II) above
(c)  Only (III) above                                 (d)  Only (IV) above
(e)  All (I), (II), (III) and (IV) above are wrong.
54.
Consider the following statements:
I.     A class can be declared as both abstract and final.
II.     A class declared as final can be extended by defining a sub-class.
III.    Resolving calls to methods dynamically at run-time is called late binding.
IV.   The class Object defined by Java need not be a super class of all other classes.
Identify the correct statement from the following:
(a)  Both (I) and (II) above                       (b)  Both (III) and (IV) above
(c)  Both (I) and (III) above                      (d)  Both (II) and (IV) above
(e)  Only (III) above.
55.
Identify, from among the following, the incorrect descriptions related to Java :
(a)   Java Virtual Machine translates byte code into its own system’s machine language and runs the resulting machine code
(b)   The arithmetic operations *, /, %, + and – have the same level of precedence
(c)   Comments do not cause any action to be performed during the program execution
(d)   All variables must be given a type when they are declared
(e)   Java variable names are case-sensitive.
56.
Consider the following statement(s) about Java:
I.     All white-space characters (blanks) are ignored by the compiler.
II.     Java keywords can be used as variable names.
III.    An identifier does not begin with a digit and does not contain any spaces.
IV.   The execution of Java applications begins at method main.
Which of them is correct?
(a)  Both (I) and (III) above                      (b)  Both (II) and  (IV) above
(c)  Both (I) and (II) above                       (d)  (III) and (IV) above
(e)  All (I), (II), (III) and (IV) above.
57.
Consider the following data types in Java :
I.  Int                       II.  Boolean              III.  Double              IV.  String                V.  Array.
Which of them are simple data types?
(a)  Both (I) and (II) above                       (b)  (I), (II), (III) and (IV) above
(c)  (I), (II) and (III) above                         (d)  (II) and (III) above
(e)  All (I), (II), (III), (IV) and (V) above.
58.
For what values respectively of the variables gender and age would the Java expression gender == 1 && age >= 65 become true?
(a)  gender = 1, age = 60                        (b)  gender = 1, age = 50
(c)  gender = 1, age = 65                        (d)  gender = 0, age = 70
(e)  gender = 0, age = 55.
59.
Consider the following Java program :
       public class Compute {

              public static void main (string args [ ])
              {
                     int result, x ;
                     x = 1 ;
                     result = 0;
                     while (x < = 10) {
                            if (x%2 = = 0) result + = x ;
                     + + x ;
              }
              System.out.println(result) ;
              }
       }
Which of the following will be the output of the above program?
(a)  55                     (b)  30                     (c)  25                     (d)  35                     (e)  45.
60.
Which of the following statements about Java Threads is correct?
(a)   Java threads don’t allow parts of a program to be executed in parallel
(b)   Java is a single-threaded language
(c)   Java’s garbage collector runs as a high priority thread
(d)   Ready, running and sleeping are three states that a thread can be in during its life  cycle
(e)   Every java application is not multithreaded.


Answers 


51.
Answer : (e)
Reason : Extending is the mechanism in which reimplementing an inherited method in a sub class to perform a different task from the parent class.
52.
Answer : (c)
Reason : According to the concept of Constructor C is right choice.
53.
Answer : (b)
Reason : Except b above all are contradictory to the functionality of package.
54.
Answer : (e)
Reason : Except e above all are contradictory to the functionality of classes concept of java
55.
Answer : (b)
Reason : The rule of precedence for arithmetic operations is *,/,+or- from left to right.
56.
Answer : (d)
Reason : Remaining all are contradictory to the statements with respect to java.
57.
Answer : (c)
Reason : String and array don’t fall into the category of simple datatypes.
58.
Answer : (c)
Reason : && is the short circuit operator which sees that all conditions should be true then only it will evaluate to true.
59.
Answer : (b)
Reason : B is the right choice remaining all are contradictory to the execution of program
60.
Answer : (d)
Reason : Ready, running and sleeping  which are three states that a thread can be in during its life  cycle.



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



3 comments :

  1. This comment has been removed by the author.

    ReplyDelete
  2. 51 - Re-implementing an inherited method in a sub class to perform a different task from the parent class is called " Overriding " not " extending "

    ReplyDelete
    Replies
    1. They got me confused.I was searching for "overriding" in the options

      Delete