Give: What is the result?
A.
The program fails to execute due to runtime error
B.
An exception is thrown at runtime
C.
Compilation fails
D.
1525
E.
13
Give: What is the result?
Give: What is the result?
A.
The program fails to execute due to runtime error
B.
An exception is thrown at runtime
C.
Compilation fails
D.
1525
E.
13
Code Question:
public class Alpha {
public String[] main = new String[2];
Alpha (String[] main) {
for (int ii = 0, ii < main.length; ii++) {
this.main[ii] = main[ii] + 5;
}
}
public void main() {
System.out.print(main[0] + main[1]);
}
}
public class Test {
public static void main(String[] args) {
Alpha main = new Alpha(args);
main.main();
}
}
And the commands:
javac Test.java
java Test 1 2
Output:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code – variable ii is already defined in constructor Alpha(java.lang.String[])
at Alpha.(Alpha.java:4)
at Test.main(Test.java:4)
i got 1525 as output