In: Computer Science
In Java
1. Which term best describes a "A uses B" class relationship? word
answer:
2. choose correct one:
What are some of the ways a class can exhibit dependency?
A. A class can invoke the methods of another class.
B. A method within a class can accept an object of the same class.
C. A class can rely on a constant defined in another class.
D. All of the above.
Which if the following statements is FALSE regarding arrays of objects?
A. Objects stored in an array are automatically instantiated when the array is created.
B. Attempting to print out an empty array of objects will generate a NullPointerException.
C. An array of objects initially holds null references.
D. An array of objects is actually an array of references to the objects.
What symbol changes a typical parameter to a variable parameter list?
A :
B *
C ...
D ?
Which of the following rules is TRUE regarding variable parameter lists?
A. A variable parameter list can appear in any order in a list of formal arguments.
B. A method can only have one variable parameter list in its list of formal parameters.
C. A variable parameter list can be the only formal argument in a method.
D. You cannot use a variable parameter list in a constructor.
3. Fill in the Blanks
The keyword [_____] is used to establish an inheritance relationship.
The existing class is also known as the [_____] class.
4. When should the protected modifier be used?
A. When you want all classes to access variables or methods from any other classes.
B. When you want a derived class to access a variable or method from the (originally) existing class.
C. When you don't want any variable or method to be accessible outside the class.
D. When you want a single method or variable to be shared among all objects.
5. The super reference is typically used by the child class to call which type of method? Word Answer:
6. Fill in the Blanks
A new method must have the same [_____] as the existing method in order to perform overriding..
thanks for the question, here are the answers
=======================================================================
1. extends, example: Class A extends B
2. Option A is not correct, if a class can invoke the
methods of another class then there is no dependency
Option B: is correct, by accepting an object of the
same class we are exhibiting dependency
Option C: constants defined in another class is not
achieving dependency
3. A. Objects stored in an array are automatically instantiated
when the array is created. is FALSE
when we create an array we are creating null references and not
actual objects
What symbol changes a typical parameter to a variable parameter
list? Answer : ...
B. A method can only have one variable parameter list in its
list of formal parameters. is the only true statement
3.
Answer extends, by using the keyword extends we establish an
inheritance relationship
4.
B. When you want a derived class to access a variable or
method from the (originally) existing class.
protected access specifier is used only when a class extends
another class, and we want the child
class to access the parent member variables.
5. Answer: constructor, we used super keyword to invoke parent
constructors
6. Answer: name and signature ( argument list)