失效链接处理 |
Java选择题40道全英文带答案 PDF 下载
本站整理下载:
提取码:veah
相关截图:
主要内容:
1、 Read the following program:
public class test {
public static void main(String [] args) {
int x = 3;
int y = 1;
if (x = y)
System.out.println("Not equal");
else
System.out.println("Equal");
}
}
What is the result?
A.The output is equal
B. The output in not Equal
C. An error at " if (x = y)" causes compilation to fall
D. The program executes but no output is show on console.
Answer: C
2、Which of the following lines will compile without warning or error.
A .float f=1.3;
B.char c="a";
C.byte b=257;
D.int i=10;
Answer:D
3、What will happen if you try to compile and run the following code
public class MyClass {
public static void main(String arguments[]) {
amethod(arguments);
}
public void amethod(String[] arguments) {
System.out.println(arguments);
System.out.println(arguments[1]);
}
}
A.error Can't make static reference to void amethod.
B. error method main not correct
C. error array must include parameter
D.amethod must be declared with String
Answer:A
4、Which of the following will compile without error
A.import java.awt.*;
package Mypackage;
class Myclass {}
B.package MyPackage;
import java.awt.*;
class MyClass{}
C.package MyPackage;
import java.awt.*;
class MyClass{}
Answer:C
5、A byte can be of what size
A. -128 to 127
B. (-2 power 8 )-1 to 2 power 8
C. -255 to 256
D.depends on the particular implementation of the Java Virtual machine
Answer:A
6、What will be printed out if this code is run with the following command line? public class myprog{
public static void main(String argv[]) {
System.out.println(argv[2]);
}
}
A. myprog
B. good
C. morning
D. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"
Answer:D
7、What will happen when you compile and run the following code?
public class MyClass{
static int i;
public static void main(String argv[]){
System.out.println(i);
}
}
A. Error Variable i may not have been initialized
B. null
C. 1
D. 0
Answer:D
8、Which of the following lines will compile without warning or error.
A .float f=1.3;
B.char c="a";
C.byte b=257;
D.int i=10;
Answer:D
9、What will happen if you try to compile and run the following code?
Public class Q{
Public static void main(String arg[]){
Int anar[] = new int[5];
System.out.println(anar[0]);
}
}
A.Error:anar is referenced before itt is initialized
B.Null
C.0
D.5
|