Home Tutorial Java Scjp Part1 SCJP Module-1 Question-12

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-12
Posted on: July 7, 2010 at 12:00 AM
Advertisement
The given program check your core java concepts and helps for SCJP examination.

Given a sample code:

1 public class Sample1 {
2 public static void main(String[] args) {
3 for (int i = 0; i < 2; i++) {
4 System.out.println(getValue(101));
}}

5 public static int getValue(int i) {
6 return (short) (Math.random() * i);
}}

What will be the result of above code ?

(1) Compilation fails because of an error at line 4
(2) Compilation fails because of an error at line 5
(3) Compilation fails because of an error at line 6
(4) Compile and run successfully with with two random number as output

Answer

(4)

Advertisement

Related Tags for SCJP Module-1 Question-12:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 7, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com