What is encapsulation? How can it be enforced in Java?

What will be an ideal response?


Encapsulation is the principle that objects should be self-governing. In other words, an object's internal data
should be protected from outside access. Encapsulation can be enforced in Java by making instance variables private.

Computer Science & Information Technology

You might also like to view...

What is the value in x after this code is executed? int i = 4; int x = ++i;

A. 4 B. 5 C. 6 D. The statement won’t compile.

Computer Science & Information Technology

The Windows Help button, a question mark, is located in the ________ of most windows

A) top right corner B) bottom right corner C) top left corner D) bottom left corner

Computer Science & Information Technology

A trendline can be added to a chart to help with problem prediction

Indicate whether the statement is true or false.

Computer Science & Information Technology

This chart area determines what field the bars on the chart represent.

A. Axis B. Series C. Legend D. Data

Computer Science & Information Technology