Flashcards
CSCI 1302 Test II
Cards in this deck (12)
- 1Briefy describe the difference between protected, private, and public levels of visibility.Private is the level of visibility where access is only available in the class it was defined in meanwhile, Protected makes access only available to the class it was defined in and any of its child classes. Public grants access everywhere.
- 2Briefly describe the differences of subclasses and superclasses.superclass is more about the generalization of a type thing while, subclass is more of a specialized version of a type of thing.
Person(superclass) and Employee(subclass) - 3What is the difference between "this" and "super" keywords?"this" and "super" keyword are both reference variables, though the "super" keyword references methods and constructors from the super class. "this" keyword references objects of the class your in.
- 4What are the differences between overriding and overloading?overriding is a feature that allows a subclass to provide specific implementation of a method that is already provided by one of its super classes. Overloading allows for different methods to have the same name but different number of parameters and/or different types. overloading happens in the same class and overriding happens in a different class.
- 5Briefly describe the abstract class. How is an abstract class like a concrete class and how does it differ?Abstract classes cannot be instantiated but can have constructors and non-abstract methods with no restrictions on attributes.Also does not describe a physical thing such as handing someone an actual Animal. Concrete class can actually be instantiated. Though both Concrete and Abstract can have constructors and attributes.
- 6What are interfaces and how would one be written?It's like an abstract class but it contains only abstract methods. It can be written as public interface "name of interface"{ public abstract datatype methodName(parameter if any);
} - 7What is the difference between aggregation and inheritance.Inheritance is a "Is-A relationship where you are deriving from a parent class to a child class. Aggregation is a Whole-Part relationship where one thing is apart of another thing.
- 8What is Polymorphism?allows for an object to take on many different forms. More importantly refer to an instance of one if its subclasses.
- 9What is a wrapper class?A class that is wrapped around a primitive datatype.
- 10What does it mean to tokenize a string. How is it done in Java?It means to break a string into its component parts. You do it in java by calling the "splitMethod" which will tokenize it on its delimiters and return a string array
- 11String str = "The cow jumped over the moon."; What is the value of the following? str.substring(15); remember: index starts from 0!!!!Index 15 is the "o" in over... and since no ending index was provided, (ex (15, 19)) it will end at the end of the string returning "over the moon"
- 12String str = "The cow jumped over the moon."; What is the value of the following? str.substring(8, 14);this will return the substring "jumped"