cse 1322 lab and lecture final exam review questio
Geschreven voor
CSE
CSE
CSE
Alle documenten voor dit vak (282)
Verkoper
Volgen
Hkane
Ontvangen beoordelingen
Voorbeeld van de inhoud
CSE 1322 Lab and Lecture Final Exam Review
What is inheritance? - ANS-a fundamental principle of object-oriented programming. It allows a
class to "inherit" (behavior or characteristics) of another, more general class and it allows a new
class to "absorb" an existing class's members and it saves time by reusing proven and
debugged high-quality software
The class from which we inherit is referred to as - ANS-parent class or base class / super class
What does the keyword base indicate? - ANS-that the base class must be used allows access
to its methods, constructors and member variables. Using base(), we can call the constructor of
the base class. Using base.Method(...) we can invoke a method of the base class, pass
parameters to it and use its results. Using base.field we can get the value of a member variable
from the base class or assign a different one to it
When inheriting a class, - ANS-our constructors must call the base class constructor, so that it
can initialize its member variables.
The keyword protected: - ANS-defines class members which are not visible to users of the class
(those who initialize and use it), but are visible to all inheriting classes (descendants)
The keyword protected internal: - ANS-defines class members which are both internal, i.e.
visible within the entire assembly, and protected, i.e. not visible outside the assembly, but visible
to classes who inherit it (even outside the assembly)
When a base class is inherited: - ANS-All of its public, protected and protected internal
members (methods, properties, etc.) are visible to the inheriting class. - All of its private
methods, properties and member-variables are not visible to the inheriting class. - All of its
internal members are visible to the inheriting class, only if the base class and the inheriting class
are in the same assembly (the same Visual Studio project).
Downcasting - ANS-casting a superclass to a subclass
A method, which can be overridden, is called - ANS-virtual
What is the difference between overloading and overriding methods? - ANS-overloading is when
there are 2 methods with the same name but different parameters but overriding is when
inherited methods are being redefined in another class
The class with which inherit from the parent class is referred to as either one of these: - ANS-a
derived class, a sub class, or child class
,Can you instantiate an abstract class? - ANS-no
Polymorphism - ANS-where a variable is changing types while the program is running
What does inheritance allow? - ANS-a new class to "absorb" an existing class's members
How does inheritance save time? - ANS-by reusing proven and debugged high-quality software
UML - ANS-Unified Modeling Language
UML Diagram - ANS-graphical representation of relationship between classes and is used for
depicting objects and object oriented concepts
When should inheritance be used? - ANS-when classes are similar
What does inheritance support? - ANS-through an extended / derived class supports code
reuse.
A method override occurs when two methods in the same class have the exact same method
signature. True or False? - ANS-False
toString( )(Java) or ToString() (C#) is a method that is in the Object class that is inherited by all
Java / C# classes. True or False? - ANS-True
When a set of methods have the same name but different types/number of parameters in the
same class, they are called: - ANS-Overloaded methods
Abstract methods are used in defining - ANS-classes that need no methods implemented
he reserved word super (in Java) or base (in C#). <method name> is used call the method
which is defined in - ANS-the parent class
A class can inherit from the methods from its classes. - ANS-super, parent, abstract, or
interfaces
What is the goal of encapsulation? - ANS-To hide the values or state of a structured an object
inside a class, preventing unauthorized direct access to them
Since toString() is a method that is in the Object class, any call to the toString() method refers to
the toString( ) method in the Object class unless - ANS-specifically overridden in the child class
The unique feature of an abstract class is that - ANS-a subclass that extends it doesn't need to
have the abstract reserved word in its declaration.
, In a UML diagram, the arrows - ANS-point up to classes they inherit from
What does @Override do? - ANS-tells the compiler to check the override is correct
Equals(Object) Method - ANS-Determines whether the specified object is equal to the current
object.
Equals(Object, Object) Method - ANS-Determines whether the specified object instances are
considered equal.
Finalize( ) Method - ANS-- if you wish to execute code just before an object is destroyed by the
garbage collector, create a _______ method in the class and place the code there
- accepts no arguments
- void return type
Allows an object to try to free resources and perform other cleanup operations before it is
reclaimed by garbage collection.
GetHashCode( ) Method - ANS-Serves as the default hash function
GetType( ) Method - ANS-Gets the Type of the current instance
MemberwiseClone( ) Method - ANS-Creates a shallow copy of the current Object
ReferenceEquals(Object, Object) Method - ANS-Determines whether the specified Object
instances are the same instance
ToString( ) Method - ANS-Returns a string that represents the current object
clone( ) Method - ANS-makes a new object with the same state as an existing object and
creates and returns a copy of this object
equals(Object obj) Method - ANS-Indicates whether some other object is "equal to" this one
getClass( ) Method - ANS-Returns the runtime class of this Object
hashCode( ) Method - ANS-Returns a hash code value for the object
notify( ) Method - ANS-Wakes up a single thread that is waiting on this object's monitor
notifyAll( ) Method - ANS-Wakes up all threads that are waiting on this object's monitor
toString( ) Method - ANS-Returns a string representation of the object
Voordelen van het kopen van samenvattingen bij Stuvia op een rij:
Verzekerd van kwaliteit door reviews
Stuvia-klanten hebben meer dan 700.000 samenvattingen beoordeeld. Zo weet je zeker dat je de beste documenten koopt!
Snel en makkelijk kopen
Je betaalt supersnel en eenmalig met iDeal, creditcard of Stuvia-tegoed voor de samenvatting. Zonder lidmaatschap.
Focus op de essentie
Samenvattingen worden geschreven voor en door anderen. Daarom zijn de samenvattingen altijd betrouwbaar en actueel. Zo kom je snel tot de kern!
Veelgestelde vragen
Wat krijg ik als ik dit document koop?
Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.
Tevredenheidsgarantie: hoe werkt dat?
Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.
Van wie koop ik deze samenvatting?
Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper Hkane. Stuvia faciliteert de betaling aan de verkoper.
Zit ik meteen vast aan een abonnement?
Nee, je koopt alleen deze samenvatting voor €7,39. Je zit daarna nergens aan vast.