Free Oracle 1Z0-829 Exam Questions

Become Oracle Certified with updated 1Z0-829 exam questions and correct answers

Page:    1 / 132      
Total 660 Questions | Updated On: May 15, 2025
Add To Cart
Question 1

Question ID: UK8291153
Given code of Test.java file:
package com.examtest.ocp;
 
import java.util.ArrayList;
import java.util.List;
 
class Person {
    private String name;
    private int age;
    
    Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
    public String toString() {
        return "Person[" + name + ", " + age + "]";
    }
    
    public boolean equals(Person obj) {
        if(obj instanceof Person) {
            Person person = (Person)obj;
            if(this.name.equals(person.name) && this.age == person.age) {
                return true;
            }
        }
        return false;
    }
}
 
public class Test {
    public static void main(String[] args) {
        List<Person> persons = new ArrayList<>();
        persons.add(new Person("Liam", 25));
        persons.add(new Person("Liam", 27));
        persons.add(new Person("Liam", 25));
        persons.add(new Person("Liam", 25));
        
        persons.remove(new Person("Liam", 25));
        
        for(Person person : persons) {
            System.out.println(person);
        }
    }
}
What is the result?


Answer: D
Question 2

Question ID: UK8293789
Given code of Test.java file:
package com.examtest.ocp;
 
class Base {
    public void log() throws NullPointerException {
        System.out.println("Base: log()");
    }
}
 
class Derived extends Base {
    public void log() throws RuntimeException {
        System.out.println("Derived: log()");
    }
}
 
public class Test {
    public static void main(String[] args) {
        Base obj = new Derived();
        obj.log();
    }
}
What is the result?


Answer: B
Question 3

Question ID: UK8292860
Given code of Test.java file:
package com.examtest.ocp;
 
class Car {
    void speed(Byteval) { //Line n1
        System.out.println("DARK"); //Line n2
    } //Line n3
 
    void speed(byte... vals) {
        System.out.println("LIGHT");
    }
}
 
public class Test {
    public static void main(String[] args) {
        byte b = 10; //Line n4
        new Car().speed(b); //Line n5
    }
}
Which of the following needs to be done so that LIGHT is printed on to the console?


Answer: B
Question 4

Question ID: UK8293780
Given code of Test.java file:
package com.examtest.ocp;
 
interface Blogger {
    default void blog() throws Exception {
        System.out.println("GENERIC");
    }
}
 
class TravelBlogger implements Blogger {
    public void blog() {
        System.out.println("TRAVEL");
    }
}
 
public class Test {
    public static void main(String[] args) {
        Blogger blogger = new TravelBlogger(); //Line n1
        ((TravelBlogger)blogger).blog(); //Line n2
    }
}
What is the result?


Answer: D
Question 5

Question ID: UK8298570
Consider below code of Test.java file:
package com.examtest.ocp; 
 
public class Test extends String {
    @Override
    public String toString() {
        return "TEST";
    }
    
    public static void main(String[] args) {
        Test obj = new Test();
        System.out.println(obj);
    }
}
What is the result?


Answer: D
Page:    1 / 132      
Total 660 Questions | Updated On: May 15, 2025
Add To Cart

© Copyrights DumpsCertify 2025. All Rights Reserved

We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the DumpsCertify.