• 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 10 pages
Exam (elaborations)

Dsa Quiz 2 With Complete Solutions

Document preview thumbnail
Preview 2 out of 10 pages

DSA QUIZ 2 WITH COMPLETE SOLUTIONS

Content preview

DSA QUIZ 2 WITH COMPLETE
SOLUTIONS

Static - Correct Answers -opposite of instance, same for every instance of class

type of copy of .clone() - Correct Answers -shallow copy

Declare then instantiate: constructor - Correct Answers -ClassName variableName =
new Constructor()
left is declaring and right (constructor) is instantiating

same method - Correct Answers -the order of data type parameters must be different
method(parameters) is its signature

equals and toString methods if you don't write one - Correct Answers -every object has
an equals method but it will only compare reference addresses
every object has a toString method but will print a string of classnamereferenceaddress
(Television@36190af)
have to override to change

inheritance keyword - Correct Answers -extends

everything extends - Correct Answers -object class
which has...
toString
equals
clone
hashCode- returns a unique int for object

can extend - Correct Answers -one class
(one parent from inheritance)

Composition vs Inheritance - Correct Answers -composition is what an object is made
up of (data and methods/states and behaviors)
class determines its state and behavior (has a)
inheritance is when a class inherits from another class (is a)

abstract method, final/static - Correct Answers -abstract method cannot be final or static
or private
constructor cannot be abstract
abstract method cannot be called

, how to declare as abstract - Correct Answers -after accessModifier/before class or
dataType
accessModifier abstract returnType methodName( argument list ); no body for method

Subclasses of abstract Classes - Correct Answers --A subclass of an abstract class can
implement all, some, or none of the abstract methods.
-If the subclass does not implement all of the abstract methods, it must also be declared
as abstract.

Overloading vs Overriding - Correct Answers -Methods in the same class which have
the same name but have different parameters.
Parameters may be of a different type and/or the number of parameters may be
different (can be different order)
VS
Methods, one in a parent class and the other in a child class which have the same
name and
parameters. The method in the child class is invoked rather than the parent class
method.

public vs private vs protected - Correct Answers -public: anyone
private: only class
protected: everything except world

friendly: class and package, not sub or world

if have a null validation for setting a value... - Correct Answers -provide an else for a
default empty string

instantiate vs declare abstract class - Correct Answers -can declare as abstract class
but not instantiate
abstract on left, inherited nonabstract on right

Polymorphism - Correct Answers -an object of a subclass is also an object of any of its
superclasses

superclass = subclass - Correct Answers -super has to be on left if you're going to mix
(can be switched but has to be casted)
(because reference type if what its declared as and reference type is the highest it can
reach but if you're trying to assign a super class to a declared sub class, it can't reach
that high)

but then you can't call unique sub methods on object since it is type of super (method
used is determined by object its pointed too but won't compile if reference type doesn't
also have that)

Document information

Uploaded on
March 26, 2026
Number of pages
10
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$13.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.
millyphilip
3.7
(560)
Sold
2991
Followers
1963
Items
46798
Last sold
4 days 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