File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Multiple choice questions verification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Multiple choice questions verification

Jack Burned

Joined: Oct 19, 2012
Posts: 3
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


6) What is a class?
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?
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.
static method

Question 9

A method that is used to assign values to the instance variables of a class is called a
set method
get method
toString() method

Question 10

A “has a” relationship between classes represents _________ and an “is a” relationship between classes represents _________.
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 ___________.
information hiding

Question 12

The concept of derived classes is involved in _________.
information hiding

Question 13

A / An ________ variable is shared by all instances of the class. It exists even before an object is created.

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?
Rodent[] array = new Rat[10];
Rat[] array = new Rat[10];
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.
(i) only
(i) & (ii) only
(i), (ii) & (iii) only
All of them
Question 18

When a class implements an interface, it must
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?
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?
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
(i), (ii), (iii) & (iv)
(i) only
(i) & (iii) only
(ii) & (iii) only

Question 22

What is polymorphism in Java?
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?
There is no default

Question 24

What interface must a class implement in order to be a listener for button ActionEvents?

Question 25

What is an Applet?
An interactive website
A type of computer
A graphical user interface
A Java program that is run through a web browser

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if the correct answers are posted/indicated here
anyone searching will get those answers,
making the test useless.
Jack Burned

Joined: Oct 19, 2012
Posts: 3
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
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 45292
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

Joined: Jun 09, 2003
Posts: 4632
we discourage handing out complete solutions,
but encouraging cheating is OK?
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
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

Joined: Oct 13, 2005
Posts: 45292
No, a constructor is not a method.
Since you appear not to have handed in the answers yet, I shall terminate this discussion now.
I agree. Here's the link:
subject: Multiple choice questions verification
It's not a secret anymore!