Anda di halaman 1dari 4

1.Which is the most accurate description of the code reuse philosophy?

A programming philosophy that promotes stealing your classmates' code.


A programming philosophy that promotes protecting data and hiding implementation
in order to preserve the integrity of data and methods.
A programming philosophy that promotes simpler, more efficient coding by using
existing code for new applications. (*)
A programming philosophy that promotes having no concern about the security of
code.

2.What keyword is used to inherit a superclass?

public
new
extends (*)
this

3.What is a hierarchy?
A keyword that allows subclasses to access methods, data, and constructors from their
parent class.
A programming philosophy that promotes simpler, more efficient coding by using
existing code for new applications.
A structure that categorizes and organizes relationships among ideas and concepts of
things with the most general at the top and the most specific at the bottom. (*)
A programming philosophy that promotes protecting data and hiding implementation
in order to preserve the integrity of data and methods.
4.Static classes can have different access specifiers than the parent class. True or false?
True (*)
False
5.Static classes can exist as inner classes. True or false?
True (*)
False
6.Which of the following access modifiers doesn't work with a static variable?
protected
friendly (*)
public
private
default
7.If we override the toString() method with the code below, what would be the result of
printing?

It would print the string returned from the method. The console screen would display:
{0, 18, 215, 64, 11, 42}
It would print the array one element at a time. The console screen would display: 0 18
215 64 11 42
It would print the array backwards. The console screen would display: 42 11 64 215
18 0
It would print the string returned from the method. The console screen would display:
[0,18,215,64,11,42,] (*)

8.If Sandal extends Shoe, it is possible to declare an object such that Sandal s = new Shoe();
True
False (*)
9.Which of the following would be most beneficial for this scenario?

Joe is a college student who has a tendency to lose his books. Replacing them is
getting costly. In an attempt to get organized, Joe wants to create a program that will
store his textbooks in one group of books, but he wants to make each book type the
subject of the book (i.e. MathBook is a book). How could he store these different
subject books into a single array?
Using polymorphism. (*)
This is not possible. Joe must find another way to collect the books.
By ignoring the subject type and initializing all the book as objects of type Book.
By overriding the methods of Book.

10.It is possible to overload a method that is not a constructor. True or False?


True (*)
False
11.Which of the following is a possible way to overload constructors?

12.It is possible to overload a method that is not a constructor. True or False?


True (*)
False
13.The following code creates an object of type Animal. True or false?
Animal a=new Animal();
True (*)
False
14.A class can have multiple constructors. True or false?
True (*)

False
15. Which of the following creates a method that returns a boolean value?

Anda mungkin juga menyukai