题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-05-24 02:06:36

[单项选择] public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age && name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?() 
A.  return super.hashCode();
B.  return name.hashCode() + age * 7;
C.  return name.hashCode() + comment.hashCode() /2;
D.  return name.hashCode() + comment.hashCode() / 2 - age * 3;

更多"public class Person "的相关试题:

[单项选择] class Account {   private int balance;   public void setBalance(int b) { balance = b; }  public int getBalance() { return balance; }   public void clearBalance() { balance = 0; }   }   哪一个改变可以使 Account 类线程安全?() 
A. 在第2行加 synchronized 修饰符。
B. 在第3行加 synchronized 修饰符。
C. 在第3行、第4行和第6行加 synchronized 修饰符。
D. 在第4行、第6行和第8行加 synchronized 修饰符。
[单项选择] class Foo {  private int x;  publicFoo(intx) {this.x=x; }  public void setX( int x) { this.x = x; }  public int getX() { return x; }  }   public class Gamma {  static Foo fooBar( Foo foo) {  foo = new Foo( 100);  return foo;  }  public static void main( String[] args) {  Foo foo = new Foo( 300);  System.out.print( foo.getX() + “-“);  Foo fooFoo = fooBar( foo);  System.out.print( foo.getX() + “-“);  System.out.print( fooFoo.getX() + “-“);  foo = fooBar( fooFoo);  System.out.print( foo.getX() + “-“);  System.out.prmt( fooFoo.getX());  }  }  What is the output of this program?()
A.  300-100-100-100-100
B.  300-300-100-100-100
C.  300-300-300-100-100
D.  300-300-300-300-100
[多项选择] class BaseClass{   private float x= 1.0f;   protected void setVar (float f) {x = f;}   }   class SubClass exyends BaseClass {   private float x = 2.0f;   //insert code here  8. }   Which two are valid examples of method overriding?()
A.  Void setVar(float f) {x = f;}
B.  Public void setVar(int f) {x = f;}
C.  Public void setVar(float f) {x = f;}
D.  Public double setVar(float f) {x = f;}
E.  Public final void setVar(float f) {x = f;}
F.  Protected float setVar() {x=3.0f; return 3.0f; }
[单项选择] You have 17GB of private files on drive D on your Windows 2000 Professional computer. You have shared the files as private_files. You do not want other users to see this share name in the browse list. You want all other share names to continue to appear in the browser list.  What should you do? ()
A. Stop the computer browser service, and disable the startup state. 
B. Change the comment for the share to hidden:Yes 
C. Change the share name to private_files$. 
D. Add a hidden entry to the  HKLMSystem/currentcontrolset/services/larmanserver/shares/private_files registry value entry. 
[单项选择] public class Alpha{  private static Character() ids;  public static void main( String[] args){  ids = new Character[args.length];  for (int i=0; iids[i] = new Character( args[i] );  System.out.print( ids[i] );  }  }  }   What is correct?()  
A.  Compilation fails.
B.  The code runs with no output.
C.  An exception is thrown at runtime.
D.  The code runs, outputing a concatenated list of the arguments passed to the program.
[多项选择] class BaseClass{  private float x= 1.0f;  protected void setVar (float f) {x = f;}  } class SubClass extends BaseClass   {  private float x = 2.0f;  //insert code here 16. }   Which two are valid examples of method overriding?()     
A.  Void setVar(float f) {x = f;}
B.  Public void setVar(int f) {x = f;}
C.  Public void setVar(float f) {x = f;}
D.  Public double setVar(float f) {x = f;}
E.  Public final void setVar(float f) {x = f;}
F.  Protected float setVar() {x=3.0f; return 3.0f; }
[单项选择] 在J2EE中,在自己编写的Bean中有代码:  Private PropertyChangeSupport changes = new PropertyChangeSupport (this):  Changes对象的作用是(): 
A. 使用Bean自动实现方法:addPropertyChangeListener和removePropertyChangeListener方法
B. 保持属性变化监听者列表,并点火属性变化事件
C. 通过内省功能,让该Bean继承Listener
D. 使该Bean的作为Listener
[单项选择] 在J2EE中,在自己编写的Bean中有代码:  private PropertyChangeSupport changes=new PropertyChangeSupport(this);  changes对象的作用是()   
A. 使该Bean自动实现方法:addPropertyChangListener和removePropertyChangeListener方法
B. 保持属性变化监听者列表,并点火属性变化事件
C. 通过内省功能,让该Bean集成Listener
D. 使该Bean的作用为Listener
[单项选择] public class Person {  private name;  public Person(String name) {  this.name = name;  }  public int hashCode() {  return 420;  }  }  Which is true?() 
A.  The time to find the value from HashMap with a Person key depends on the size of the map.
B.  Deleting a Person key from a HashMap will delete all map entries for all keys of typePerson.
C.  Inserting a second Person object into a HashSet will cause the first Person object to beremoved as a duplicate.
D.  The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.
[单项选择] public class Plant {  private String name;  public Plant(String name) { this.name = name; }  public String getName() { return name; }  }  public class Tree extends Plant {  public void growFruit() { }  public void dropLeaves() { }  }  Which is true?() 
A.  The code will compile without changes.
B.  The code will compile if public Tree() { Plant(); } is added to the Tree class.
C.  The code will compile if public Plant() { Tree(); } is added to the Plant class.
D.  The code will compile if public Plant() { this(”fern”); } is added to the Plant class.
E.  The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
[单项选择] public class Pet{   private String name;   public Pet(){   System.out.print(1);  }   public Pet(String name){   System.out.print(2);  }   }   public class Dog extends Pet{  public Dog(String name){   //这里隐藏了一句代码:super.pet();   System.out.print(3);  }   }   执行new Dog(“棕熊”);后程序输出是哪项?() 
A.  23
B.  1 3
C.  123
D.  321
[多项选择] public class Key {  private long id1;  private long 1d2;  // class Key methods  }  A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()
A.  public int hashCode()
B.  public boolean equals(Key k)
C.  public int compareTo(Object o)
D.  public boolean equals(Object o)
E.  public boolean compareTo(Key k)
[多项选择] public class Foo {  private int val;  public foo(int v) (val = v;)  }  public static void main (String [] args)  {  Foo a = new Foo (10);  Foo b = new Foo (10);  Foo c = a;  int d = 10;  double e = 10.0;  }  Which three logical expression evaluate to true?()
A.  (a ==c)
B.  (d ==e)
C.  (b ==d)
D.  (a ==b)
E.  (b ==c)
F.  (d ==10.0)
[单项选择] public class Test {  private static float[] f = new float[2];  public static void main(String args[]) {  System.out.println(“f[0] = “ + f[0]);  }  }   What is the result?()  
A.  f[0] = 0
B.  f[0] = 0.0
C.  Compilation fails.
D.  An exception is thrown at runtime.

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码