Java Programming OOPs
Questions 121 to 130
| 
121. | 
Which of
  the following can Java run from a Web browser exclusively?  
 | ||||||||||
| 
Which of
  the following language is Architecture-Neutral?  
 | |||||||||||
| 
How the
  main method header is written in Java?  
 | |||||||||||
| 
What is the
  extension name of a Java source code file? 
 | |||||||||||
| 
Which of
  the following is not the reserved
  words in java?  
 | |||||||||||
| 
Suppose  
static
  void nPrint(String message, int n) { 
   while (n > 0) { 
     System.out.print(message); 
     n--; 
   } 
} 
What is the
  printout of the call Print('a', 4)? 
 | |||||||||||
| 
Analyze the
  following code. 
public
  class Test { 
public
  static void main(String[] args) { 
  System.out.println(max(1, 2));  
} 
 public static double max(int num1, double
  num2) { 
   System.out.println("max(int, double)
  is invoked"); 
 if (num1 > num2) 
   return num1; 
 else 
   return num2; 
 } 
      public static double max(double num1,
  int num2) { 
System.out.println("max(double,
  int) is invoked"); 
if
  (num1 > num2) 
  return num1; 
 else 
   return num2;  
 } 
} 
 | |||||||||||
| 
Analyze the
  following code. 
public
  class Test { 
public
  static void main(String[] args) { 
  System.out.println(m(2));  
} 
public
  static int m(int num) { 
  return num; 
} 
public
  static void m(int num) { 
  System.out.println(num); 
} 
} 
 | |||||||||||
| 
What is
  Math.rint(3.5)? 
 | |||||||||||
| 
Analyze the
  following code: 
public
  class Test {  
public
  static void main(String[] args) {  
  int[] x = new int[5];  
  int i; 
  for (i = 0; i < x.length; i++) 
    x[i] = i; 
  System.out.println(x[i]); 
} 
} 
 | 
Answers
| 
121. | 
Answer :  (b) 
Reason  :       Applets
  run from a web browser. | 
| 
Answer :  (a) 
Reason  :       Java
  is architecture neutral. | |
| 
Answer :  (c) 
Reason  :       public
  static void main(String[] args) the 
  main method header is written in Java | |
| 
Answer :  (a) 
Reason  :       the
  extension name of a Java source code file .Java | |
| 
Answer :  (e) 
Reason  :       All
  are the reserved words of java. | |
| 
Answer :  (e) 
Reason  :       I
  nvalid call because char 'a' cannot be passed to string message | |
| 
Answer :  (b) 
Reason  :       This
  is known as ambiguous method invocation | |
| 
Answer :  (a) 
Reason  :       You
  cannot override the methods based on the type returned. | |
| 
Answer :  (d) 
Reason  :       rint
  returns the nearest even integer as a double since 3.5 is equally close to
  3.0 and 4.0. | |
| 
Answer :  (c) 
Reason  :       After
  the for loop i is 6. x [5] is out of bounds. | 
 
 
thank you.
ReplyDeletejava tutorial
java tutorial