Skip to content
Pass Any WGU OA Exam Now & Pay After You Pass. Contact Us!
  1. Home
  2. WGU Exams
  3. WGU D286
  4. Set 2
WGU D286 · Java Fundamentals

WGU D286 Practice Questions – Set 2

50 multiple-choice questions with answers and detailed explanations. Untimed — choose an answer to check it instantly.

Question 1 of 50

What does the break statement do in a switch-case structure?

Question 2 of 50

Which of the following is a valid way to compare two strings for equality?

Question 3 of 50

What will be the output of System.out.println(5 * 2 + 3); ?

Question 4 of 50

How can you declare a method that takes no arguments?

Question 5 of 50

What is the result of the following operation: int[] arr = {1, 2, 3}; arr[1] = 5; System.out.println(arr[1]); ?

Question 6 of 50

Which of the following statements correctly creates a new object of a class named Car ?

Question 7 of 50

How do you declare a method that returns an integer value?

Question 8 of 50

What is the purpose of the import statement?

Question 9 of 50

How do you create a multi-dimensional array in Java?

Question 10 of 50

What will happen if you try to access an index outside the bounds of an array?

Question 11 of 50

What does the continue statement do in a loop?

Question 12 of 50

What will be the output of System.out.println(“Hello”.length()); ?

Question 13 of 50

How do you convert a string to an integer in Java?

Question 14 of 50

Which of the following is the correct way to define an interface in Java?

Question 15 of 50

What is the main purpose of the final keyword?

Question 16 of 50

How do you check if a string is empty in Java?

Question 17 of 50

Which of the following statements is used to handle exceptions in Java?

Question 18 of 50

What is the output of the following code snippet? System.out.println(7 % 4);

Question 19 of 50

How do you define a constructor in Java?

Question 20 of 50

Which of the following keywords is used to create a subclass in Java?

Question 21 of 50

What is the output of System.out.println(“abc”.charAt(1)); ?

Question 22 of 50

Which of the following statements is true regarding arrays in Java?

Question 23 of 50

What is the purpose of the super keyword?

Question 24 of 50

What does the default keyword indicate in a switch statement?

Question 25 of 50

What is the purpose of the throws keyword in method declarations?

Question 26 of 50

How can you concatenate two strings in Java?

Question 27 of 50

Which of the following is the correct syntax for an enhanced for loop?

Question 28 of 50

What does the instanceof operator do in Java?

Question 29 of 50

How can you make a variable accessible across multiple classes?

Question 30 of 50

What is the purpose of a constructor overloading in Java?

Question 31 of 50

Which of the following statements is used to declare a package in Java?

Question 32 of 50

How do you throw an exception manually in Java?

Question 33 of 50

What keyword is used to prevent a class from being subclassed?

Question 34 of 50

How do you retrieve the size of an ArrayList in Java?

Question 35 of 50

What will happen if you try to modify a string in Java?

Question 36 of 50

Which of the following is a valid declaration of an enum in Java?

Question 37 of 50

How can you handle multiple exceptions in a single catch block?

Question 38 of 50

What will be the output of System.out.println(10 + 5 + ” is the sum.”); ?

Question 39 of 50

Which method is used to convert a string to uppercase?

Question 40 of 50

How can you remove an element from an ArrayList?

Question 41 of 50

What will be the output of System.out.println(3 + 4 + “Java”); ?

Question 42 of 50

What is the purpose of the finally block in Java?

Question 43 of 50

How do you compare two objects for reference equality?

Question 44 of 50

Which keyword is used to define a constant variable in Java?

Question 45 of 50

What is the default value of an uninitialized int variable in Java?

Question 46 of 50

How do you handle an unchecked exception in Java?

Question 47 of 50

Which of the following methods can be used to iterate over elements in a List?

Question 48 of 50

What is the purpose of the static keyword?

Question 49 of 50

How do you convert a string to a character array in Java?

Question 50 of 50

What is the purpose of the volatile keyword in Java?

Set 2 complete

You scored 0%

0 correct out of 0 answered (50 questions in this set).

Next: Set 3

Struggling with WGU D286?

If this exam is giving you a hard time, let us be your helping hand. Contact us, and we'll provide the assistance you need to pass and move forward.

Chat Now