Question: JAVA Question 1 Declaring instance variables ________ is known as data hiding or information hiding. a. secure b. private c. static d. masked Question 2

JAVA

Question 1

Declaring instance variables ________ is known as data hiding or information hiding.

a. secure

b. private

c. static

d. masked

Question 2

Assume class Book has been declared. Which set of statements creates an array of Books?

a.

Book[] books; books = new Book[numberElements];

b.

Book[] books]; books = new Book()[numberElements];

c.

new Book() books[]; books = new Book[numberElements];

d. All of the above.

Question 3

Which of the following class members should usually be private?

a. Methods.

b. Constructors.

c. Variables (or fields).

d. All of the above.

Question 4

When must a program explicitly use the this reference?

a. Accessing a private variable.

b. Accessing a public variable.

c. Accessing a local variable.

d. Accessing an instance variable that is shadowed by a local variable.

Question 5

Which of the following statements is true?

a. Methods and instance variables can both be either public or private.

b. Information hiding is achieved by restricting access to class members via keyword public.

c. The private members of a class are directly accessible to the clients of a class.

d. None of the above is true.

Question 6

What happens when this is used in a constructors body to call another constructor of the same class if that call is not the first statement in the constructor?

a. A compilation error occurs.

b. A runtime error occurs.

c. A logic error occurs.

d. Nothing happens. The program compiles and runs.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!