Submitted by c-admin on Sat, 05/25/2019 - 22:39
Which line(s) in the following code will cause a compilation error?
static import java.lang.System.*; //1
class $$ //2
{
static public void main(String... _$_) //3
{
String _ = ""; //4
for(int $=0; ++$ < _$_.length; ) //5
_ += _$_[$]; //6
out.println(_); //7
}
}
Select 1 option
A. 1
B. 2
C. 3
D. 4
E. 5
F. 6
G. 7
H. None of the lines is invalid.
Submitted by c-admin on Sat, 05/25/2019 - 22:35
Consider the following two java files:
//in file SM.java
package x.y;
public class SM{
public static void foo(){ }; }
//in file TestClass.java
//insert import statement here //1
public class TestClass{
public static void main(String[] args){
foo();
}
}
What should be inserted at //1 so that TestClass will compile and run?
Select 2 options
A. import static x.y.*;
B. import static x.y.SM;
C. import static x.y.SM.foo;
D. import static x.y.SM.foo();
E. import static x.y.SM.*;
Submitted by c-admin on Sat, 05/25/2019 - 22:28
The following are the complete contents of TestClass.java file. Which packages are automatically imported?
class TestClass{
public static void main(String[] args){
System.out.println("hello");
}
}
Select 2 options
A. java.util
B. System
C. java.lang
D. java.io
E. String
F. The package with no name.
Submitted by c-admin on Sat, 05/25/2019 - 22:18
Consider the following two classes defined in two .java files.
//in file /root/com/foo/X.java
package com.foo;
public class X{
public static int LOGICID = 10;
public void apply(int i){
System.out.println("applied");
}
}
//in file /root/com/bar/Y.java
package com.bar;
//1 <== INSERT STATEMENT(s) HERE
public class Y{
public static void main(String[] args){
System.out.println(X.LOGICID);
}
}
What should be inserted at //1 so that Y.java can compile without any error?
Select 1 option
A. import static X;
B. import static com.foo.*;
C. import static com.foo.X.*;
D. import com.foo.*;
E. import com.foo.X.LOGICID;
Submitted by c-admin on Sat, 05/25/2019 - 22:09
Consider the following directory structure shown in Image 1 that displays available folders and classes and the code is given below.
class StockQuote{
Stock stock;
public StockQuote(Stock s) {
}public double computePrice(){
return Helper.getPricer(stock).price();
} }
Assuming that the code uses valid method calls, what statements must be added to the above class?

Select 2 options
A. import com.enthu.*;
B. import com.*.*;
C. import *.*.*;
D. import com.*;
E. import com.enthu.rad.*;
F. import all;
Pages