java Fred1 hello walls

Which two will compile, and can be run successfully using the command:

java Fred1 hello walls

Which two will compile, and can be run successfully using the command:

java Fred1 hello walls

A.
class Fred1{
public static void main (String args) {
System.out.println(args[1]);
}
}

B.
class Fred1{
public static void main (String [] args) {
System.out.println(args[1]);
}
}

C.
class Fred1 {
public static void main (String [] args) {
System.out.println (args);
}
}

D.
class Fred1 {
public static void main (String [] args) {
System.out.println (args [2]);
}
}

Explanation:
Incorrect answers:
A: Will not compile. array is required, not a string.
D: Array out of bounds at runtime.



Leave a Reply 7

Your email address will not be published. Required fields are marked *


Jazz

Jazz

B,D

OutPuts:

A- Compile Time Error.
B- hello
C- [Ljava.lang.String;@60607135
D- walls

Pavan

Pavan

B,C
D- array index out of bound

Cheng

Cheng

B,D

compile, and successfully

OutPuts:

A- Compile Time Error.
B- hello
C- [Ljava.lang.String;@60607135
D- walls

James

James

The Answer is B, C.

Kalil Peixoto

Kalil Peixoto

Answers are B,C..

As on letter D it tries to access index 2 on the array, it will throw an Exception as the size of the array are only 2.

Martin Lee

Martin Lee

Hi, I have passed OCAJP 7 (1Z0-803) EXAM with 98%. I would like to share my exam experience with those who are going to take this exam. I learned the Mala Gupta’s book and PassLeader 1Z0-803 dumps. They were describing and explaning the key points of the exam very clearly. To be honest, I read Mala Gupta’s book mainly because of the interest how the basic things in Java are handled internally and I started to take the PassLeader 1Z0-803 dumps (http://www.passleader.com/1z0-803.html), around one week before the exam. Good luck to future Oracle exam takers!