100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

CMSC132 - Final Exam Review Questions and Answers

Rating
-
Sold
-
Pages
8
Grade
A+
Uploaded on
23-06-2025
Written in
2024/2025

CMSC132 - Final Exam Review

Institution
CMSC 132
Course
CMSC 132









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
CMSC 132
Course
CMSC 132

Document information

Uploaded on
June 23, 2025
Number of pages
8
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

CMSC132 - Final Exam Review

Subclasses - answer- inherits all properties, behaviors, and fields of its superclass
- inherits private fields and methods in its super classes, but it cannot directly access
them
- can have more methods than its superclass
- classes can only extend one superclass
- subclass is a type of a superclass object
- constructor automatically calls its superclass's default constructor (error if it doesn't
have one)
- can explicitly invoke its superclass constructor using super
- execution order: most parent to most sub
- can redefine (override) methods in a superclass, but must have the same name and
signature
- can call an overridden method in a superclass using super( )
- can define a field with the same name as a superclass field

Super classes - answer- can refer to an object of any of its subclasses

object-name instanceof classname - answer- returns true if object is of the type
classname or if is an object of any of its subclasses

object-name.getClass() - answer- returns a reference to something called a class object
(unique object for each class in program), which can be compared using == or equals()
to see if object is the same class as another object

Dynamic binding - answer- the type of a object that a superclass reference refers to
determines which method gets called (when methods are overridden)
- DOES NOT APPLY TO STATIC METHODS

Final - answer- methods cannot be overridden by subclasses
- classes cannot be extended (no subclasses)

The Object class - answer- the (direct/indirect) superclass of all other classes in Java
- doesn't have fields, but it does have methods (equals( ) and toString( ))

Interfaces - answer- A collection of:
~ Constants
~ Method signatures (or prototypes), but no implementations
- a class can only implement one interface at a time
- Restriction of interfaces: CAN'T INSTANTIATE AN INTERFACE
- Reference of an interface type object - an object of any class that implements the
interface

, Composition - answer- using instance variables that refer to other objects in a class

Initialization block - answer- used to initialize fields of a class
- code that is executed once per object

Static initialization block - answer- code that is executed once for each class used while
program is running

When can fields be initialized? - answer- at point of declaration
- in a constructor
- in an initialization block

What is the order of field initialization? - answer1. Declarations and initialization blocks
(in the order they appear)
2. Constructor

Comparable Interface - answer- In a class implementing it, A.compareTo(B) should
return a negative value if A < B, 0 if A == B, and a positive value if A > B
- an array/ArrayList containing elements of a class that implements Comparable can be
sorted using Arrays.sort( ) or Collections.sort( ) (respectively)

Abstract classes - answer- classes with abstract methods must be abstract ("abstract" in
class heading)
- cannot be instantiated, but subclasses can extend an abstract class
- subclasses provide implementation for all abstract methods
- final methods cannot be overridden by subclass methods
- concrete object (of a non-abstract subclass) can be created, and referred to by a
reference of an abstract superclass type

What happens when an abstract class implements an interface? - answer- It's possible
for the abstract class to not implement all of the interface's methods

Types of Errors - answer- Compile-time (syntax) errors
- Runtime errors
- Logic Errors

Compile-time (syntax) Errors - answer- Errors in code construction, such as
typographical, grammatical, or type mismatch problems

Runtime Errors - answer- Operations that are illegal or impossible to execute
- Treated as exceptions in Java

Logic Errors - answer- These are operations leading to an incorrect program state
- They represent a problem in the design or implementation of the algorithm used

Get to know the seller

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.
Dreamer252 NBursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
478
Member since
2 year
Number of followers
293
Documents
21304
Last sold
1 week ago

4.0

115 reviews

5
60
4
22
3
18
2
2
1
13

Recently viewed by you

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

Frequently asked questions