CSE 1322 EXAM 3 FULL REVISION NOTES WITH
OBJECT-ORIENTED PROGRAMMING AND JAVA
FUNDAMENTALS CONCEPTS
◉ When should inheritance be used?
Answer: when classes are similar
◉ What does inheritance support?
Answer: 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?
Answer: 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?
Answer: True
◉ When a set of methods have the same name but different
types/number of parameters in the same class, they are called:
Answer: Overloaded methods
,◉ Abstract methods are used in defining
Answer: 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
Answer: the parent class
◉ A class can inherit from the methods from its classes.
Answer: super, parent, abstract, or interfaces
◉ What is the goal of encapsulation?
Answer: 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
Answer: specifically overridden in the child class
◉ The unique feature of an abstract class is that
Answer: a subclass that extends it doesn't need to have the abstract
reserved word in its declaration.
,◉ In a UML diagram, the arrows
Answer: point up to classes they inherit from
◉ What does @Override do?
Answer: tells the compiler to check the override is correct
◉ Equals(Object) Method
Answer: Determines whether the specified object is equal to the
current object.
◉ Equals(Object, Object) Method
Answer: Determines whether the specified object instances are
considered equal.
◉ Finalize( ) Method
Answer: - 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
Answer: Serves as the default hash function
◉ GetType( ) Method
Answer: Gets the Type of the current instance
◉ MemberwiseClone( ) Method
Answer: Creates a shallow copy of the current Object
◉ ReferenceEquals(Object, Object) Method
Answer: Determines whether the specified Object instances are the
same instance
◉ ToString( ) Method
Answer: Returns a string that represents the current object
◉ clone( ) Method
Answer: 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
Answer: Indicates whether some other object is "equal to" this one
OBJECT-ORIENTED PROGRAMMING AND JAVA
FUNDAMENTALS CONCEPTS
◉ When should inheritance be used?
Answer: when classes are similar
◉ What does inheritance support?
Answer: 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?
Answer: 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?
Answer: True
◉ When a set of methods have the same name but different
types/number of parameters in the same class, they are called:
Answer: Overloaded methods
,◉ Abstract methods are used in defining
Answer: 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
Answer: the parent class
◉ A class can inherit from the methods from its classes.
Answer: super, parent, abstract, or interfaces
◉ What is the goal of encapsulation?
Answer: 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
Answer: specifically overridden in the child class
◉ The unique feature of an abstract class is that
Answer: a subclass that extends it doesn't need to have the abstract
reserved word in its declaration.
,◉ In a UML diagram, the arrows
Answer: point up to classes they inherit from
◉ What does @Override do?
Answer: tells the compiler to check the override is correct
◉ Equals(Object) Method
Answer: Determines whether the specified object is equal to the
current object.
◉ Equals(Object, Object) Method
Answer: Determines whether the specified object instances are
considered equal.
◉ Finalize( ) Method
Answer: - 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
Answer: Serves as the default hash function
◉ GetType( ) Method
Answer: Gets the Type of the current instance
◉ MemberwiseClone( ) Method
Answer: Creates a shallow copy of the current Object
◉ ReferenceEquals(Object, Object) Method
Answer: Determines whether the specified Object instances are the
same instance
◉ ToString( ) Method
Answer: Returns a string that represents the current object
◉ clone( ) Method
Answer: 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
Answer: Indicates whether some other object is "equal to" this one