Oracle 1Z0-501 Actual Free Exam Questions & Community Discussion
Given:
1 . public class Foo {
2 . private int val;
3 . public foo(int v) (val = v;)}
4 . public static void main (String [] args){
5 . Foo a = new Foo (10);
6 . Foo b = new Foo (10);
7 . Foo c = a;
8 . int d = 10;
9 . double e = 10.0;
1 0. }
1 1. }
Which three logical expression evaluate to true? (Choose Three)
1 . public class Foo {
2 . private int val;
3 . public foo(int v) (val = v;)}
4 . public static void main (String [] args){
5 . Foo a = new Foo (10);
6 . Foo b = new Foo (10);
7 . Foo c = a;
8 . int d = 10;
9 . double e = 10.0;
1 0. }
1 1. }
Which three logical expression evaluate to true? (Choose Three)
Correct Answer: B,D,E
Vote an answer
Given:
1 . public class X {
2 . public object m () {
3 . object o = new float (3.14F);
4 . object [] oa = new object [1];
5 . oa[0]= o;
6 . o = null;
7 . oa[0] = null;
9 . return o;
9 . }
1 0.}
When is the float object created in line 3, eligible for garbage collection?
1 . public class X {
2 . public object m () {
3 . object o = new float (3.14F);
4 . object [] oa = new object [1];
5 . oa[0]= o;
6 . o = null;
7 . oa[0] = null;
9 . return o;
9 . }
1 0.}
When is the float object created in line 3, eligible for garbage collection?
Correct Answer: D
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,C
Vote an answer
Given:
8 . int index = 1;
9 . boolean[] test = new Boolean[3];
1 0. boolean foo= test [index];
What is the result?
8 . int index = 1;
9 . boolean[] test = new Boolean[3];
1 0. boolean foo= test [index];
What is the result?
Correct Answer: A
Vote an answer
Which four types of objects can be thrown using the throw statement? (Choose Four)
Correct Answer: A,C,D,E
Vote an answer
Given:
1 . public class ArrayTest {
2 . public static void main (String[]args){
3 . float f1[], f2[];
4 . f1 = new float [10];
5 . f2 = f1;
6 . System.out.printIn ("f2[0]=" + f2[0]);
7 .}
8 .}
What is the result?
1 . public class ArrayTest {
2 . public static void main (String[]args){
3 . float f1[], f2[];
4 . f1 = new float [10];
5 . f2 = f1;
6 . System.out.printIn ("f2[0]=" + f2[0]);
7 .}
8 .}
What is the result?
Correct Answer: E
Vote an answer
CORRECT TEXT
Exhibit:
1 . public class X {
2 . public static void main (String[]args) {
3 . string s = new string ("Hello");
4 . modify(s);
5 . System.out.printIn(s);
6 .}
7 .
8 . public static void modify (String s){
9 . s += "world!";
1 0.}
1 1. }
What is the result?
E.The program runs and prints "Hello"
F.An error causes compilation to fail.
G.The program runs and prints "Hello world!"
H.The program runs but aborts with an exception.
Exhibit:
1 . public class X {
2 . public static void main (String[]args) {
3 . string s = new string ("Hello");
4 . modify(s);
5 . System.out.printIn(s);
6 .}
7 .
8 . public static void modify (String s){
9 . s += "world!";
1 0.}
1 1. }
What is the result?
E.The program runs and prints "Hello"
F.An error causes compilation to fail.
G.The program runs and prints "Hello world!"
H.The program runs but aborts with an exception.
Correct Answer:
A
You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access modifier that will accomplish this objective?
Correct Answer: E
Vote an answer
0
0
0
10
