black

Java认证考试综合练习

登录

单项选择题

class Sock2 {  
String color;  
public boolean equals(Object o) {  
return color.equals(((Sock2)o).color);  
} }  
class TestSocks {  
public static void main(String [] args) {  
Sock2 s1 = new Sock2(); s1.color = "blue";  
Sock2 s2 = new Sock2(); s2.color = "blue";  
if (s1.equals(s2)) System.out.print("equals ");  
if (s1 == s2) System.out.print("== ");  
}  
}  
结果为:()  
 
 

A.==
B.equals
C.equals ==
D.无结果输出

相关考题

单项选择题 1. abstract class Color2 {   2. //insert code here   3. }   4.   5. public class Blue2 extends Color2 {   6. public String getRGB() { return "blue"; }   7. }   和4个声明:   public abstract String getRGB();   abstract String getRGB();   private abstract String getRGB();   protected abstract String getRGB();   分别插入到第2行,有多少行可以编译?()

单项选择题 import java.util.*;  class Banana3 {  public static void main(String [] args) {  int x = 2;  Banana3 b = new Banana3();  b.go(x);  }  static { x += x; }  void go(int x) {  ++x;  System.out.println(x);  }  }  结果为:()

单项选择题 现有如下五个声明:   int a_really_really_really_long_variable_name = 5;  int _hi =6;   int big = Integer.getInteger("7");   int $dollars = 8;   int %percent = 9;   有几个可以通过编译?()

All Rights Reserved 版权所有©易学考试网(yxkao.com)

备案号:湘ICP备2022003000号-3