Free Oracle 1Z0-501 Practice Test & Real Exam Questions

  • Exam Code/Number: 1Z0-501
  • Exam Name/Title: Java Certified Programmer
  • Certification Provider: Oracle
  • Corresponding Certification: Other Oracle Certification
  • Exam Questions: 147
  • Updated On: May 29, 2026
Given:
1. public class Foo {
2 . public static void main (String [] args){
3 .StringBuffer a = new StringBuffer ("A");
4 .StringBuffer b = new StringBuffer ("B");
5 .operate (a,b);
6 .system.out.printIn{a + "," +b};
7 . )
8 . static void operate (StringBuffer x, StringBuffer y){
9 .x.append {y};
1 0.y = x;
1 1.)
1 2.}
What is the result?
Correct Answer: F Vote an answer
Given:
1 . public class SyncTest {
2 . private int x;
3 . private int y;
4 . public synchronized void setX (int i) (x=1;)
5 . public synchronized void setY (int i) (y=1;)
6 . public synchronized void setXY(int 1)(set X(i); setY(i);)
7 . public synchronized Boolean check() (return x !=y;)
8 . )
Under which conditions will check () return true when called from a different class?
Correct Answer: B Vote an answer
Exhibit:
1 . import java.io.IOException;
2 . public class ExceptionTest(
3 . public static void main (String[]args)
4 . try (
5 . methodA();
6 .) catch (IOException e)(
7 . system.out.printIn("Caught IOException");
8 .) catch (Exception e)(
9 . system.out.printIn("Caught Exception");
1 0.)
1 1. )
1 2. public void methodA (){
1 3. throw new IOException ();
14.)
15. )
What is the result?
Correct Answer: A Vote an answer
Which is a valid identifier?
Correct Answer: A 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?
Correct Answer: A Vote an answer
Which two CANNOT directly cause a thread to stop executing? (Choose Two)
Correct Answer: B,D Vote an answer
Given:
1 . switch (i){
2 . default:
3 . System.out.printIn("Hello");
4 . )
What is the acceptable type for the variable i?
Correct Answer: C Vote an answer
Given:
1 . public class ConstOver {
2 . public ConstOver (int x, int y, int z){
3 .}
4 . }
Which two overload the ConstOver constructor? (Choose Two)
Correct Answer: B,E Vote an answer
Given:
1 . public class Test {
2 . public static void leftshift(int i, int j) {
3 .i<<=j;
4 .}
5 . public static void main(String args[]){
6 . int i = 4, j = 2;
7 . leftshift(i, j);
8 . System.out.printIn(i);
9 .}
1 0. }
What is the result?
Correct Answer: C Vote an answer
Exhibit:
1 . public class test (
2 .private static int j = 0;
3 .
4 .private static boolean methodB(int k) (
5 .j += k;
6 .return true;
6 . )
7 .
8 . public static void methodA(int i) {
9 .boolean b:
1 0.b = i < 10 | methodB (4);
1 1.b = i < 10 || methodB (8);
1 2.)
1 3.
1 4.public static void main (String args[] }(
1 5.methodA (0);
1 6.system.out.printIn(j);
1 7.)
1 8.)
What is the result?
Correct Answer: E Vote an answer