Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple choice questions verification

 
Greenhorn
Posts: 3
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
if the correct answers are posted/indicated here
anyone searching will get those answers,
making the test useless.
 
Jack Burned
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Michael Dunn wrote:if the correct answers are posted/indicated here
anyone searching will get those answers,
making the test useless.



Oh no this is a so called one time test and I am the only taking it for scholarship eligibility, not to worry
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
No 1: correct
No 2: A very bad question. Depending on how you read it, it could be true or false. I think the correct answer is false.
No 3: correct
No 4: correct
No 5: read this.
No 6: incorrect
No 7: correct
No 8: All answers are incorrect. A constructor is not a method.
No 9: correct
No 10: correct
No 11: incorrect, I think
No 12: Another bad question, but I think incorrect
No 13: incorrect
No 16: incorrect
No 19: incorrect
No 20: Bad question. Two of the answers would be correct.
No 21: Bad question. Multiple inheritance does not exist in Java. You can only mimic it, but the answer you gave will be regarded as correct.
No 23: incorrect
No 24: correct
No 25: correct
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
we discourage handing out complete solutions,
but encouraging cheating is OK?
 
Ranch Hand
Posts: 101
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Campbell Ritchie wrote:No 1: correct
No 8: All answers are incorrect. A constructor is not a method.



i think it's wrong constructor is a special method(so no 8 is true) and specification says
Constructors are similar to methods, but cannot be invoked directly by a
method call; they are used to initialize new class instances. Like methods, they may
be overloaded .
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
No, a constructor is not a method.
Since you appear not to have handed in the answers yet, I shall terminate this discussion now.
 
    Bookmark Topic Watch Topic
  • New Topic