,1. Multiple Choice: What is the purpose of the transient keyword
in Java?
a) To indicate that a variable is temporary
b) To denote that a field is not part of the object's serialized
state
c) To declare a variable as static
d) To mark a variable as volatile
Answer: b) To denote that a field is not part of the object's
serialized state
Rationale: The transient keyword in Java is used to indicate that
a field should not be serialized.
2. Fill-in-the-Blank: An _________ class in Java is a class that
cannot be instantiated and is often used to provide a base for
subclasses.
Answer: Abstract
Rationale: An abstract class cannot be instantiated on its own
and is used to declare common characteristics for subclasses.
3. True/False: In Java, the 'final' keyword can be used to prevent
method overriding.
Answer: True
, Rationale: The 'final' keyword prevents a method from being
overridden in a subclass.
4. Multiple Response: Which of the following are valid Java
identifiers? (Select all that apply)
a) _identifier
b) $identifier
c) 2ndIdentifier
d) identifier!
Answers: a) _identifier, b) $identifier
Rationale: Java identifiers can begin with a letter, the dollar sign
"$", or the underscore "_". They cannot start with a number or
contain special characters like "!".
5. Multiple Choice: Which method signature is correct for the
main method in a Java application?
a) public static void main(String args)
b) public static void main(String[] args)
c) public void static main(String[] args)
d) static public void main(String args[])
Answer: b) public static void main(String[] args)
, Rationale: The correct signature for the main method in Java
includes 'public' and 'static' modifiers, 'void' as the return type,
and a String array as the parameter.
6. Fill-in-the-Blank: The process by which one class acquires the
properties and functionalities of another class is known as
_________.
Answer: Inheritance
Rationale: Inheritance allows a class to inherit properties and
methods from another class.
7. True/False: The hashCode() method in Java returns a unique
identifier for each object.
Answer: False
Rationale: The hashCode() method is intended to provide a
unique identifier but does not guarantee uniqueness.
8. Multiple Response: Which of these are Java built-in
annotations? (Select all that apply)
a) @Override
b) @FunctionalInterface
c) @Deprecated
d) @Immutable
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller ClemAcademia. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $16.49. You're not tied to anything after your purchase.