Oracle Java Certified Programmer - 1Z0-501 模擬練習
CORRECT TEXT
Given:
AnInterface is an interface.
AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.
AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.
Which two construct an anonymous inner class? (Choose Two)
F.AnAdapter1 aa=new AnAdapter1(){}
G.AnAdapter0 aa=new AnAdapter0(){}
H.AnAdapter0 aa=new AnAdapter0(5){}
I.AnAdapter1 aa=new AnAdapter1(5){}
J.AnInterface a1=new AnInterface(5){}
Given:
AnInterface is an interface.
AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.
AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.
Which two construct an anonymous inner class? (Choose Two)
F.AnAdapter1 aa=new AnAdapter1(){}
G.AnAdapter0 aa=new AnAdapter0(){}
H.AnAdapter0 aa=new AnAdapter0(5){}
I.AnAdapter1 aa=new AnAdapter1(5){}
J.AnInterface a1=new AnInterface(5){}
正解:
B, D
Exhibit:
1 . interface foo {
2 . int k = 0;
3 . ]
4 .
5 . public class test implements Foo (
6 . public static void main(String args[]) (
7 . int i;
8 . Test test = new test ();
9 . i= test.k;
1 0.i= Test.k;
1 1.i= Foo.k;
1 2.)
1 3.)
1 4.
What is the result?
1 . interface foo {
2 . int k = 0;
3 . ]
4 .
5 . public class test implements Foo (
6 . public static void main(String args[]) (
7 . int i;
8 . Test test = new test ();
9 . i= test.k;
1 0.i= Test.k;
1 1.i= Foo.k;
1 2.)
1 3.)
1 4.
What is the result?
正解: E
Given:
1 . public class Test {
2 . public static void main (String []args){
3 . unsigned byte b = 0;
4 . b--;
5 .
6 .}
7 . }
What is the value of b at line 5?
1 . public class Test {
2 . public static void main (String []args){
3 . unsigned byte b = 0;
4 . b--;
5 .
6 .}
7 . }
What is the value of b at line 5?
正解: A
Given:
1. class super {
2. public float getNum() {return 3.0f;}
3 . )
4 .
5 . public class Sub extends Super {
6 .
7 .)
Which method, placed at line 6, will cause a compiler error?
1. class super {
2. public float getNum() {return 3.0f;}
3 . )
4 .
5 . public class Sub extends Super {
6 .
7 .)
Which method, placed at line 6, will cause a compiler error?
正解: B
Given:
1 . public class test (
2 . public static void main (String args[]){
3 .int i = 0xFFFFFFF1;
4 .int j = ~i;
5 .
6 .}
7 . )
What is the decimal value of j at line 5?
1 . public class test (
2 . public static void main (String args[]){
3 .int i = 0xFFFFFFF1;
4 .int j = ~i;
5 .
6 .}
7 . )
What is the decimal value of j at line 5?
正解: D
Given:
1 . public class MethodOver {
2 . private int x, y;
3 . private float z;
4 . public void setVar(int a, int b, float c){
5 . x = a;
6 . y = b;
7 . z = c;
8 .}
9 . }
Which two overload the setVar method? (Choose Two)
1 . public class MethodOver {
2 . private int x, y;
3 . private float z;
4 . public void setVar(int a, int b, float c){
5 . x = a;
6 . y = b;
7 . z = c;
8 .}
9 . }
Which two overload the setVar method? (Choose Two)
正解: A,D
Exhibit:
1 . public class Mycircle {
2 . public double radius;
3 . public double diameter;
4 .
5 . public void setRadius(double radius)
6 . this.radius = radius;
7 . this.diameter= radius * 2;
8 .}
9 .
1 0. public double getRadius(){
1 1. return radius;
1 2.}
1 3. }
Which statement is true?
1 . public class Mycircle {
2 . public double radius;
3 . public double diameter;
4 .
5 . public void setRadius(double radius)
6 . this.radius = radius;
7 . this.diameter= radius * 2;
8 .}
9 .
1 0. public double getRadius(){
1 1. return radius;
1 2.}
1 3. }
Which statement is true?
正解: D
Which two interfaces provide the capability to store objects using a key-value pair?
(Choose Two)
(Choose Two)
正解: D,F
The file "file.txt" exists on the file system and contsins ASCII text.
Given:
3 8. try {
3 9. File f = new File("file.txt");
4 0. OutputStream out = new FileOutputStream(f, true);
4 1. }
4 2. catch (IOException){}
What is the result?
Given:
3 8. try {
3 9. File f = new File("file.txt");
4 0. OutputStream out = new FileOutputStream(f, true);
4 1. }
4 2. catch (IOException){}
What is the result?
正解: E