I have this assignment was hoping some one could correct my assignment before I submit, all the questions I tried to answer to the best of my knowledge I really need to score this module to secure the really need scholarship... tks
1) A class must always contain a constructor, accessor methods and toString() method. --- FALSE
2) An interface can only contain abstract methods. --- TRUE
3) Each method in a class must have a unique name. --- FALSE
4) Objects of a super class can always be assigned to a subclass reference. --- FALSE , not so sure this can only happen if they are abstract Objects
5) When an instance of a class, or object, is specified as a parameter to a method, a reference to the said object is passed to the method. --- UNSURE if true or false
FROM HERE ONWARDS I MADE MY CHOICES HIGHLIGHT IN BOLD
6) What is a class?
Answer
A class is a section of the hard disk reserved for object oriented programs.
A class is used as a template to create objects.
A class is a collection of objects.
A class is a section of computer memory containing objects.
What restriction is there on using the super reference in a constructor?
Answer
Only one child class can use it.
It can only be used in the parent's constructor.
It must be used in the first statement of the constructor.
It must be used in the last statement of the constructor.
4 points
Question 8
A ________ is a special method that has the same name as the class and is invoked automatically whenever an object of the class is instantiated.
Answer
constructor
setter
getter
static method
Question 9
A method that is used to assign values to the instance variables of a class is called a
Answer
set method
get method
constructor
toString() method
Question 10
A “has a” relationship between classes represents _________ and an “is a” relationship between classes represents _________.
Answer
static class, non-static class
composition, inheritance
inheritance, composition
overriding, overloading
Question 11
Providing access to an object only through its member functions, while keeping the details private is called ___________.
Answer
information hiding
encapsulation
inheritance
modularity
Question 12
The concept of derived classes is involved in _________.
Answer
encapsulation
information hiding
polymorphism
inheritance
Question 13
A / An ________ variable is shared by all instances of the class. It exists even before an object is created.
Answer
instance
abstract
interface
static
Question 16
Assuming that class Rodent has a child class Rat and another child class Mouse. Class Mouse has a child class PocketMouse. Examine the following
Which of the following array declarations is correct for an array that is expected to hold up to 10 objects of types Rat, Mouse, and PocketMouse?
Answer
Rodent[] array = new Rat[10];
Rat[] array = new Rat[10];
I AM THINKING EITHER ONE
Rodent[10] array;
Rodent[] array = new Rodent[10];
Question 17
Which of the following statements about abstract methods/classes in
Java are true?
(i)An abstract class cannot be instantiated.
(ii)Constructors cannot be abstract.
(iii)All subclasses of an abstract class must override the abstract methods.
(iv)Static methods may be declared abstract.
Answer
(i) only
(i) & (ii) only
(i), (ii) & (iii) only
All of them
TOTALLY NO CLUE
Question 18
When a class implements an interface, it must
Answer
redefine each constant from the interface.
implement each method listed in the interface.
declare a variable for each constant in the interface.
include a private method for each method in the interface.
Question 19
What happens in a method if an unchecked exception is thrown in a try block and there is no matching catch block?
Answer
The program ignores the exception
The program halts immediately
The method throws the exception to its caller
This is not legal, so the program will not compile
Question 20
Which of the following statements about the try{} block in Java is false?
Answer
Some of the statements in a try{} block will never throw an exception.
The try{} block must appear before the catch{} blocks.
The try{} block cannot contain loops or branches.
The statements in a try{} block may throw several types of exception.
Question 21
The concept of multiple inheritance is implemented in Java by
i. extending two or more classes
ii. extending one class and implementing one or more interfaces
iii. implementing two or more interfaces
iv. all of these
Answer
(i), (ii), (iii) & (iv)
(i) only
(i) & (iii) only
(ii) & (iii) only
Question 22
What is polymorphism in Java?
Answer
It is when a single super class has many subclasses.
It is when a single variable is used with several different types of related objects at different places in a program.
It is when a program uses several different types of objects, each with its own variable.
It is when a class has several methods with the same name but different parameter types.
Question 23
What is the default layout manager for a panel?
Answer
BorderLayout
There is no default
FlowLayout
GridLayout
Question 24
What interface must a class implement in order to be a listener for button ActionEvents?
Answer
ActionListener
EventHandler
TextListener
Runnable
Question 25
What is an
Applet?
Answer
An interactive website
A type of computer
A graphical user interface
A Java program that is run through a web browser