Oracle java fundamentals final quiz answers




Final Quiz answers

 Question 1: Which two statements are true about getter methods?

  • A) Getter methods typically return void.
  • B) Getters have a public access modifier.
  • C) You must have a setter method if you have a getter method.
  • D) Getters usually accept no arguments.

Answer 1: B, D

Question 2: If fields aren't initialized, they take on a default value.

  • A) True
  • B) False

Answer 2: A

Question 3: What will happen when you try to access an object reference with a null value?

  • A) NullPointerException.
  • B) The value null is retrieved from the memory location.
  • C) An empty object is returned.
  • D) You will get a compilation error.

Answer 3: A

Question 4: You create an Employee object with a String employeeName field. What is the default value for employeeName?

  • A) null
  • B) A space
  • C) "Name"
  • D) "default"

Answer 4: A

Question 5: Which statement is true about the default constructor of a class?

  • A) Java automatically provides a constructor for every class.
  • B) You must write a default constructor.
  • C) The default constructor always returns void.
  • D) Default constructor should have at least one argument.

Answer 5: A

Question 6: How would you instantiate the Employee class from a main method located in another class?

  • A) Employee emp1 = new Employee();
  • B) Employee emp1 = new Employee(50000);
  • C) Employee emp1 = new Employee(50000, "Syam");
  • D) Employee emp1 = new Employee("Syam", 50000).

Answer 6: D

Question 7: An object must be instantiated before its non-static fields and methods can be accessed.

  • A) True
  • B) False

Answer 7: A

Question 8: The fields and methods of the Math class cannot be directly accessed as they are static.

  • A) True
  • B) False

Answer 8: A

Question 9: Which three can vary in overloaded methods?

  • A) The names of parameters
  • B) Method return type.
  • C) Types of parameters.
  • D) Order of parameters.
  • E) Number of parameters.

Answer 9: C, D, E

Question 10: You can write more than one constructor in a class.

  • A) True
  • B) False

Answer 10: A

Question 11: How would you complete this code so that one add method calls the other add method?

java Copy code

public int add(int a, int b, int c) { return(a+b+c); } public int add(int a, int b){ //Complete this line. }

  • A) return (a, b);
  • B) return add(a, b, c);
  • C) return add(a, b, 0);
  • D) return (a, b, c).

Answer 11: C

Question 12: The structure of a class consists of properties and behaviors.

  • A) True
  • B) False

Answer 12: A

Question 13: First, you decide the radius of each circle in the logo. Then using the same radius you draw 5 circles of the same size. All these circles will have properties like radius and color. All circles share behaviors to calculate circumference and area. Can you identify which of the following is an object?

  • A) fiveCircles
  • B) circumference
  • C) radius
  • D) circle

Answer 13: D

Question 14: You have created an Employee class with all required fields and methods. 10 employees join the company. Should you copy and paste the Employee class for all 10 employees?

  • A) True
  • B) False

Answer 14: B

Question 15: Which is NOT a compilation error?

  • A) int y; y++;
  • B) int x=2
  • C) y = 3 + * 5;
  • D) x = ( 3 + 5;

Answer 15: B

Question 16: What are two disadvantages of adding print statements for debugging?

  • A) Print statements cannot print the values of variables.
  • B) It’s tedious to remove print statements.
  • C) Print statements cannot print the values of an object’s fields.
  • D) Too many print statements lead to information overload.

Answer 16: B, D

Question 17: The size of an ArrayList can grow as needed.

  • A) True
  • B) False

Answer 17: A

Question 18: Which two are limitations of an array of primitives (i.e., int[] x)?

  • A) You need to create your methods to manipulate array contents.
  • B) You can create only one array in a class.
  • C) You cannot overwrite the contents of an array once initialized.
  • D) The size of the array is fixed during array creation and cannot grow once initialized.

Answer 18: A, D

Question 19: Which is NOT a benefit of the ArrayList class?

  • A) An ArrayList shrinks as you remove elements.
  • B) You can remove all of the elements of an ArrayList with a method.
  • C) An ArrayList grows as you add elements.
  • D) You can use an ArrayList list to store Java primitive values (like int).

Answer 19: A

Question 20: How could you declare an ArrayList so that it can store true or false values?

  • A) ArrayList<boolean> arrList = new ArrayList<>();
  • B) ArrayList<true, false> arrList = new ArrayList<>();
  • C) ArrayList<Boolean> arrList = new ArrayList<>();
  • D) ArrayList<True, False> arrList = a ArrayList<>();

Answer 20: C

Question 21: What is the danger of catching a generic Exception type as shown below?

java Copy code

int[] array = {10, 20, 30}; int b = 0; try { System.out.println("1"); int c = (array[3] / b); System.out.println("2"); } catch(Exception ex) { System.out.println(ex.toString()); }

  • A) The details of the Exception object ex are too general to be useful.
  • B) An Exception will never occur.
  • C) An ArithmeticException cannot be caught.
  • D) An ArrayIndexOutOfBoundsException cannot be caught.

Answer 21: A

Question 22: An Image is an object that describes the location of a graphics file.

  • A) True
  • B) False

Answer 22: B

Question 23: Which method is used for mouse click events?

  • A) setOnMouseDragged()
  • B) setOnMouseClicked()
  • C) setOnMouseMoved()
  • D) setOnMouseReleased()

Answer 23: B

Question 24: In JavaFX, how do you create a button with the label "Click Me"?

  • A) Button button = new Button("Click Me");
  • B) Button button = Button("Click Me");
  • C) Button button = createButton("Click Me");
  • D) Button button = create("Click Me");

Answer 24: A

Question 25: Which layout manager allows you to create a resizable grid of elements in JavaFX?

  • A) BorderPane
  • B) FlowPane
  • C) GridPane
  • D) StackPane

Answer 25: C

 






















Midterm Quiz






















Section 3 Quiz 1









Section 3 Quiz 2









Section 4 Quiz 1









Section 4 Quiz 2








Section 5 Quiz










Section 6 Quiz










Section 7 Quiz 1









Section 7 Quiz 2









Section 8 Quiz








Section 9 Quiz






Comments

  1. You have written very good content we liked it very much!! https://vataliyacomputerclasses.wordpress.com/2024/10/10/coding-classes-in-vadodara-gujarat/, https://vataliya-soft-tech.blogspot.com/2024/09/coding-class-in-vadodara-gujarat.html

    ReplyDelete

Post a Comment

Popular posts from this blog