可以从该类的外部访问的方法是()
A: public void getValue()
B: private void getValue()
C: void public getValue()
D: void private getValue()
A: public void getValue()
B: private void getValue()
C: void public getValue()
D: void private getValue()
举一反三
- 在某类中存在一个方法“int getValue(int x)”,以下能作为这个方法重载的是____ A: public getValue(int x); B: void getValue(int x); C: int getValue(int x,int y); D: int get(int x);
- 给定以下代码:interface I { void setValue(int val); int getValue(); }以下哪段代码能编译? A: interface A implements I { void increment(); } B: class A extends I { void increment(); } C: abstract class C implements I { int value; public void setValue(int val) { value = val; } public int getValue() { return value; } } D: class A extends I { int value; void setValue(int val) { value = val; } int getValue() { return value; } }
- 给定以下代码:interface I { void setValue(int val); int getValue(); }以下哪段代码能编译? A: class A extends I { void increment(); } B: abstract class C implements I { int value; public void setValue(int val) { value = val; } public int getValue() { return value; } } C: class A extends I { int value; void setValue(int val) { value = val; } int getValue() { return value; }} D: interface A implements I { void increment(); }
- 中国大学MOOC: 以下Pair泛型类public class Pair<K, V> { public Pair(K key, V value) { this.key = key; this.value = value; } public K getKey(); { return key; } public V getValue(); { return value; } public void setKey(K key) { this.key = key; } public void setValue(V value) { this.value = value; } private K key; private V value;}经过类型擦除后,变成以下类public class Pair { public Pair(Object key, Object value) { this.key = key; this.value = value; } public Object getKey() { return key; } public Object getValue() { return value; } public void setKey(Object key) { this.key = key; } public void setValue(Object value) { this.value = value; } private Object key; private Object value;}
- 一个类的方法在声明时可以同时使用以下多个关键字( )。 A: void、public、extends B: private、long、static C: static、public、private D: final、abstract、void