two demonstrate an “is a” relationship? (Choose Two)
A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Sha pe { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal{private Species species;}
E. ponent { }
Class Container ponent (
ponent[ ] children;
Answer :de
2. Given:
1. package foo;
2.
3. public class Outer (
4. public static class Inner (
5. )
6. )
Which statement is true?
A. An instance of the Inner class can be constructed with “new ()”
B. An instance of the inner class cannot be constructed outside of package foo
C. An instance of the inner class can only be constructed from within the outer class
D. From within the package bar, an instance of the inner class can be constructed with “new inner()”
Answer:c
:
1 public class enclosinggone{
2 public class insideone{}
3 }
4 public class inertest{
5 public static void main (String[] args){
6 enclosingone eo = new enclosingone();
7 //insert code here
8 }
}
Which statement at line 7 constructs an instance of the inner class?
InsideOne ei = InsideOne();
B. ei = InsideOne();
C InsideOne ei = InsideOne();
InsideOne ei = InsideOne();
Answer:a
4.
1) class Super{
2) public float getNum(){return ;}
3) }
4)
5) public class Sub extends Super{
6)
7) }
which method, placed at line 6, will cause piler error?
A. public float getNum(){return ;}
B. public void getNum(){}
C. public void getNum(double d){}
D. public double getNum(float d){return ;}
Answer :B
5.
1)public class Foo{
2) public static void main(String args[]){
3) try{return;}
4) finally{ ("Finally");}
5) }
6) }
what is the result?
A. The program runs and prints nothing.
B. The program runs and pri
Java试题及答案英文版 来自淘豆网m.daumloan.com转载请标明出处.