Oracle Java Certified Programmer - 1Z0-501 Exam Practice Test
CORRECT TEXT
Given:
8 . int index = 1;
9 . String [] test = new String[3];
1 0. String foo = test[index];
What is the result?
E.Foo has the value ""
B.Foo has the value null
C.An exception is thrown
D.The code will not compile
Given:
8 . int index = 1;
9 . String [] test = new String[3];
1 0. String foo = test[index];
What is the result?
E.Foo has the value ""
B.Foo has the value null
C.An exception is thrown
D.The code will not compile
Correct Answer:
B
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?
Correct Answer: C
Vote an answer
Which two interfaces provide the capability to store objects using a key-value pair?
(Choose Two)
(Choose Two)
Correct Answer: D,F
Vote an answer
Given:
1 . public class ExceptionTest {
2 . class TestException extends Exception {}
3 . public void runTest () throws TestException {}
4 . public void test () /* Point X*/ {
5 . runTest ();
6 .}
7 . }
At point X on line 4, which code can be added to make the code compile?
1 . public class ExceptionTest {
2 . class TestException extends Exception {}
3 . public void runTest () throws TestException {}
4 . public void test () /* Point X*/ {
5 . runTest ();
6 .}
7 . }
At point X on line 4, which code can be added to make the code compile?
Correct Answer: A
Vote an answer
Given:
1 . public class foo {
2 . public static void main (string[]args)
3 . try {return;}
4 . finally {system.out.printIn("Finally");}
5 . }
6 . )
What is the result?
1 . public class foo {
2 . public static void main (string[]args)
3 . try {return;}
4 . finally {system.out.printIn("Finally");}
5 . }
6 . )
What is the result?
Correct Answer: C
Vote an answer
Exhibit:
1 . import java.awt*;
2 .
3 .public class X extends Frame (
4 .public static void main(string []args)(
5 .X x = new X ();
6 . X.pack();
7 . x.setVisible(true);
8 .)
9 .
1 0. public X ()(
1 1. setlayout (new GridLayout (2,2));
1 2.
1 3. Panel p1 = new panel();
1 4. Add(p1);
1 5. Button b1= new Button ("One");
1 6. P1.add(b1);
1 7.
1 8. Panel p2 = new panel();
1 9. Add(p2);
2 0. Button b2= new Button ("Two");
2 1. P2.add(b2);
2 2.
2 3. Button b3= new Button ("Three");
2 4. add(b3);
2 5.
2 6. Button b4= new Button ("Four");
2 7. add(b4);
2 8.)
2 9. )
Which two statements are true? (Choose Two)
1 . import java.awt*;
2 .
3 .public class X extends Frame (
4 .public static void main(string []args)(
5 .X x = new X ();
6 . X.pack();
7 . x.setVisible(true);
8 .)
9 .
1 0. public X ()(
1 1. setlayout (new GridLayout (2,2));
1 2.
1 3. Panel p1 = new panel();
1 4. Add(p1);
1 5. Button b1= new Button ("One");
1 6. P1.add(b1);
1 7.
1 8. Panel p2 = new panel();
1 9. Add(p2);
2 0. Button b2= new Button ("Two");
2 1. P2.add(b2);
2 2.
2 3. Button b3= new Button ("Three");
2 4. add(b3);
2 5.
2 6. Button b4= new Button ("Four");
2 7. add(b4);
2 8.)
2 9. )
Which two statements are true? (Choose Two)
Correct Answer: A,B
Vote an answer
Which statements about static inner classes are true? (Choose Two)
Correct Answer: B,E
Vote an answer
You want a class to have access to members of another class in the same package. Which is the most restrictive access modifier that will accomplish that will accomplish this objective?
Correct Answer: B
Vote an answer
Exhibit:
1 . public class enclosingone (
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 . )
9 . )
Which statement at line 7 constructs an instance of the inner class?
1 . public class enclosingone (
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 . )
9 . )
Which statement at line 7 constructs an instance of the inner class?
Correct Answer: B
Vote an answer