Assume that country is set for each class.
Given:
10. public class Money {
11. private String country, name;
12. public getCountry() { return country; }
13.}
and:
24. class Yen extends Money {
25. public String getCountry() { return super.country; }
26. }
27.
28. class Euro extends Money {
29. public String getCountry(String timeZone) {
30. return super.getCountry();
31. }
32. }
Which two are correct?()
A. Yen returns correct values.
B. Euro returns correct values.
C. An exception is thrown at runtime.
D. Yen and Euro both return correct values.
E. Compilation fails because of an error at line 25.
F. Compilation fails because of an error at line 30.
您可能感兴趣的试卷
你可能感兴趣的试题
public class CreditCard {
private String cardlD;
private Integer limit;
public String ownerName;
public void setCardlnformation(String cardlD,
String ownerName, 28. Integer limit) {
this.cardlD = cardlD;
this.ownerName = ownerName;
this.limit = limit;
}
}
Which is true?()
A. The class is fully encapsulated.
B. The code demonstrates polymorphism.
C. The ownerName variable breaks encapsulation.
D. The cardlD and limit variables break polymorphism.
E. The setCardlnformation method breaks encapsulation.
10. interface Foo {}
11. class Alpha implements Foo {}
12. class Beta extends Alpha {}
13. class Delta extends Beta {
14. public static void main( String[] args) {
15. Beta x = new Beta();
16. // insert code here
17. }
18. }
Which code, inserted at line 16, will cause a java.lang.ClassCastException?()
A. Alpha a = x;
B. Foo f= (Delta)x;
C. Foo f= (Alpha)x;
D. Beta b = (Beta)(Alpha)x;
31. // some code here
32. try {
33. // some code here
34. } catch (SomeException se) {
35. // some code here
36. } finally {
37. // some code here
38. }
Under which three circumstances will the code on line 37 be executed?()
A. The instance gets garbage collected.
B. The code on line 33 throws an exception.
C. The code on line 35 throws an exception.
D. The code on line 31 throws an exception.
E. The code on line 33 executes successfully.
public class Test {
public static void main(String [] args) {
int x =5;
boolean b1 = true;
boolean b2 = false;
if((x==4) && !b2)
System.out.print(”l “);
System.out.print(”2 “);
if ((b2 = true) && b1)
System.out.print(”3 “);
}
}
What is the result?()
A. 2
B. 3
C. 1 2
D. 2 3
E. 1 2 3
F. Compilation fails.
G. Au exceptional is thrown at runtime.
10. public class Bar {
11.static void foo(int...x) {
12. // insert code here
13. }
14. }
Which two code fragments, inserted independently at line 12, will allow the class to compile?()
A. foreach(x) System.out.println(z);
B. for(int z : x) System.out.println(z);
C. while( x.hasNext()) System.out.println( x.next());
D. for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
Which three are valid on line 12?()
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
Given the following code:
1) class Parent {
2) private String name;
3) public Parent(){}
4) }
5) public class Child extends Parent {
6) private String department;
7) public Child() {}
8) public String getValue(){ return name; }
9) public static void main(String arg[]) {
10) Parent p = new Parent();
11) }
12) }
Which line will cause error?()
A. line 3
B. line 6
C. line 7
D. line 8
E. line 10
A. FlowLayout
B. CardLayout
C. North and South of BorderLayout
D. East and West of BorderLayout
E. GridLayout
class Parent {
String one, two;
public Parent(String a, String b){
one = a;
two = b; }
public void print(){ System.out.println(one); } }
public class Child extends Parent {
public Child(String a, String b){
super(a,b);
}
public void print(){
System.out.println(one + " to " + two);
}
public static void main(String arg[]){
Parent p = new Parent("south", "north");
Parent t = new Child("east", "west");
p.print();
t.print();
}
}
Which of the following is correct?()
A. Cause error during compilation.
B. south east
C. south to north east to west
D. south to north east
E. south east to west
public class Parent {
int change() {…}
}
class Child extends Parent {
}
Which methods can be added into class Child?()
A. public int change(){}
B. int chang(int i){}
C. private int change(){}
D. abstract int chang(){}
最新试题
What is the appropriate definition of the hashCode method in class Person?()
What is the result?()
Given that Triangle implements Runnable, and:Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute?()
Which two statements are true?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
Which statement is true?()
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()
What is the result?()
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()
Which two are possible results?()