• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 5 pages
Exam (elaborations)

Oca Exam Practice Questions And Answers 2026/2027

Document preview thumbnail
Preview 2 out of 5 pages

This document contains OCA exam practice questions and answers designed to support preparation for the 2026/2027 examination period. It provides exam-style questions with answers to help students review key concepts, test their knowledge, and identify areas that need further study.

Content preview

OCA EXAM PRACTICE QUESTIONS AND
ANSWERS 2026/2027
Can you have static classes in Java? - ANSWER-Yes and no. You cannot have top-
level static classes, but you may have nested static classes (these are mainly used in
defining one-off, utility and/or library classes where instantiation would not make sense).
You can basically declare the class final to mimic static class behavior since you
wouldn't want to extend a static class in the first place.

ArithmeticException - ANSWER-Thrown by the JVM when code attempts to divide by
zero (Runtime Exception)

ArrayIndexOutOfBoundsException - ANSWER-Thrown by the JVM when code uses an
illegal index to access an array (Runtime Exception)

ClassCastException - ANSWER-Thrown by the JVM when an attempt is made to cast
an exception to a subclass of which it is not an instance (Runtime Exception)

IllegalArgumentException - ANSWER-Thrown by the programmer to indicate that a
method has been passed an illegal or inappropriate argument (Runtime Exception)

NullPointerException - ANSWER-Thrown by the JVM when there is a null reference
where an object is required (Runtime Exception)

NumberFormatException - ANSWER-Thrown by the programmer when an attempt is
made to convert a string to a numeric type but the string doesn't have an appropriate
format (Runtime Exception)

protected void finalize() - ANSWER-called by the garbage collector on an object when
garbage collection determines that there are no more references to the object (subclass
overrides the finalize method to dispose of system resources or to perform other
cleanup)

Method overloading - ANSWER-multiple methods with the same name but with a
different signature (keep in mind "public void buzz() { }" "buzz()" is the signature)

return type and all that other stuff can be different no problem

Calling this() in Java - ANSWER-this() must be the first line of a constructor if present

Variables declared inside an interface are? - ANSWER-Implicitly public static final (keep
in mind this is why the naming conventions will be like "LEFT_MOTOR")

, Functional Interfaces and lambda expressions - ANSWER-Interface must contain ONE
abstract method, lambda expressions here may be used to represent the instance of a
functional interface

Keep in mind lambda syntax!
Also, note that there must be the same number of arguments, as well as the type of
arguments that they specify. You don't need to specify types, but if you specify one, you
must specify the other. (aka (a,b) is good, but (String a, b) is NOT)

Switch statements - ANSWER-The value of the 'expression' in a switch-case statement
must be an integer, char, short, long. Float and double are not allowed.

StringBuilder s1 = new StringBuilder("meow");
if (s1.toString() == "meow") System.out.println("four"); - ANSWER-FALSE. While both of
them evaluate to "meow", they do not both point to the "meow" in the string pool.

What is the output when new Hippopotamus() is called?
1: class Mammal {
2: public Mammal(int age) { System.out.println("1"); }
3: }
4: public class Hippopotamus extends Mammal {
5: public Hippopotamus() { System.out.println("2"); }
6: } - ANSWER-THIS CODE WILL FAIL.
Keep in mind subclasses will make a call to the superclass if no explicit call is made to
the parent constructor. Therefore, super() will be run but there is nothing to receive it,
since public Mammal(int age) exists and a default constructor is not created.

Which of the following statements can be inserted in the blank so that the code will
compile successfully? - ANSWER-There have been a few of these trick questions, to be
honest. In this case, it doesn't seem like they want what would make sense from a
programmer's point of view, but literally as the question says, whatever would fool the
compiler.

Method overriding (subclasses) - ANSWER-Cannot be more restrictive than original
(private -> protected is fine, but not vice versa)

return types must be same or a subclass of original return type AND must have the
same parameters (different parameters is overloading!)

Can you pass a null reference? - ANSWER-A null value can always be passed as a
reference. Although this will compile without issue, it will produce a
NullPointerException at runtime. (LOOK AT QUESTION WORDING AND LOOK AT
WHAT THEY'RE ASKING FOR)

Can you make a method private and abstract? - ANSWER-No, there would be literally
no point to this method, as no class would be able to implement it.

Document information

Uploaded on
September 16, 2026
Number of pages
5
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$14.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ExpertEducators
3.7
(11)
Sold
78
Followers
1
Items
3180
Last sold
2 weeks ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions