OA Exams

  • web.groovymark@gmail.com
  • December 26, 2024

Question 41

What is the purpose of the this keyword in Java?

A. To reference the current class

B. To reference the current object

C. To call a constructor

D. To create an instance of a class

Answer: B

Explanation: The this keyword is used to reference the current object.

Question 42

How do you declare a variable that can hold a decimal value in Java?

A. int myDecimal;

B. double myDecimal;

C. decimal myDecimal;

D. float myDecimal;

Answer: B

Explanation: The double data type is used to declare a variable that can hold decimal values.

Question 43

Which of the following statements is true about the final keyword?

A. It can be applied to methods, variables, and classes.

B. It can only be applied to classes.

C. It can be applied only to methods.

D. It cannot be used with variables.

Answer: A

Explanation: The final keyword can be applied to methods, variables, and classes to restrict modifications.

Question 44

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

A. 22

B. 26

C. 29

D. 20

Answer: B

Explanation: The expression evaluates to 26 based on the order of operations.

Question 45

How do you convert a primitive type to a wrapper type in Java?

A. Autoboxing

B. Boxing

C. Unboxing

D. Casting

Answer: A

Explanation: The process of converting a primitive type to a wrapper type is known as autoboxing.

Question 46

What is the output of System.out.println(“2” + 3 + 1);?

A. 6

B. 231

C. 23

D. 1

Answer: B

Explanation: The expression evaluates to "231" due to string concatenation.

Question 47

Which of the following is true about an interface in Java?

A. It can contain method implementations.

B. It can have instance variables.

C. It can extend multiple interfaces.

D. It cannot be instantiated.

Answer: C

Explanation: An interface can extend multiple interfaces, and it cannot have instance variables or implementations of methods.

Question 48

How do you make a class final in Java?

A. By using the final keyword before the class name

B. By using the static keyword

C. By using the protected keyword

D. By using the private keyword

Answer: A

Explanation: A class is made final by using the final keyword before the class name.

Question 49

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

A. 15

B. 510

C. 5.10

D. 5 + 10

Answer: B

Explanation: The expression evaluates to "510" due to string concatenation.

Question 50

Which of the following is a feature of exception handling in Java?

A. It allows for error recovery.

B. It stops program execution.

C. It can handle only runtime exceptions.

D. It is mandatory for all methods.

Answer: A

Explanation: Exception handling allows for error recovery in a program.

Complete the Captcha to view next question set.

Prev Post
WGU D286 Practice Exam Questions – Set 3 – Part 2
Next Post
WGU D286 Practice Exam Questions – Set 3 – Part 3