二、JAVA题1. Given the following code:
class Test{
private int m;
public static void fun() {
// some code...
}
}
How can the member variable m be accessible directly in the method fun()?
A. change private int m to protected int m
B. change private int m to public int m
C. change private int m to static int m
D. change private int m to int m 2. Which methods are correct overloading methods of the following method:
public void example(){...}
A. public void example( int m){...}
B. public int example(){...}
C. public void example2(){...}
D. public int example ( int m, float f){...}
Explanation: 3. Given the following code:
switch (m)
{
case 0: System.out.println("Condition 0");
case 1: System.out.println("Condition 1");
case 2: System.out.println("Condition 2");
case 3: System.out.println("Condition 3");break;
default: System.out.println("Other Condition"); }
Which values of m will cause "Condition 2" is output?
A. 0
B. 1
C. 2
D. 3
E. 4
F. None Given the following code:
1) class Example{
2} String str;
3} public Example(){
4} str= "example";
5} }
6} public Example(String s){
7} str=s;
8} }
9} }
10) class Demo extends Example{
11} }
12) public class Test{
13} public void f () {
14} Example ex = new Example("Good");
15} Demo d = new Demo("Good");
16} }
Which line will cause an error? A. line 3
B. line 6
C. line 10
D. line 14
E. line 15
Explanation:
class Test{
private int m;
public static void fun() {
// some code...
}
}
How can the member variable m be accessible directly in the method fun()?
A. change private int m to protected int m
B. change private int m to public int m
C. change private int m to static int m
D. change private int m to int m 2. Which methods are correct overloading methods of the following method:
public void example(){...}
A. public void example( int m){...}
B. public int example(){...}
C. public void example2(){...}
D. public int example ( int m, float f){...}
Explanation: 3. Given the following code:
switch (m)
{
case 0: System.out.println("Condition 0");
case 1: System.out.println("Condition 1");
case 2: System.out.println("Condition 2");
case 3: System.out.println("Condition 3");break;
default: System.out.println("Other Condition"); }
Which values of m will cause "Condition 2" is output?
A. 0
B. 1
C. 2
D. 3
E. 4
F. None Given the following code:
1) class Example{
2} String str;
3} public Example(){
4} str= "example";
5} }
6} public Example(String s){
7} str=s;
8} }
9} }
10) class Demo extends Example{
11} }
12) public class Test{
13} public void f () {
14} Example ex = new Example("Good");
15} Demo d = new Demo("Good");
16} }
Which line will cause an error? A. line 3
B. line 6
C. line 10
D. line 14
E. line 15
Explanation:
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货