Set 3

Multiple Choice Question


Consider the following code:

public class MyClass {
  protected int value = 10;

Which of the following statements are correct regarding the field value?

Select 1 option

A. It cannot be accessed from any other class.
B. It can be read but cannot be modified from any other class. 
C. It can be modified but only from a subclass of MyClass.
D. It can be read and modified from any class within the same package or from any subclass of MyClass.

Multiple Choice Question


Which of the following are correct about "encapsulation"?

Select 2 options

A. Encapsulation is same as polymorphism.
B. It helps make sure that clients have no accidental dependence on the choice of representation
C. It helps avoiding name clashes as internal variables are not visible outside.
D. Encapsulation makes sure that messages are sent to the right object at run time.
E. Encapsulation helps you inherit the properties of another class.

Multiple Choice Question


Select the correct order of restrictiveness for access modifiers... (First one should be least restrictive)

Select 1 option 

A. public < protected < package (i.e. no modifier) < private 
B. public < package (i.e. no modifier) < protected < private 
C. public < protected < private < package (i.e. no modifier) 
D. protected < package (i.e. no modifier) < private < public 
E. depends on the implementation of the class or method. 

Multiple Choice Question


For object o1 of class A to access a member(field or method) of object o2 of class B, when the member has no access modifier, class B must be...

Select 1 option

A. a subclass of A 
B. in the same package as A is in. 
C. a Super class of A 
D. a subclass but may not be in the same package. 
E. in the same package and must be a Subclass of A. 

Multiple Choice Question


Given the following definition of class, which member variables are accessible from OUTSIDE the package com.enthu.qb?

package com.enthu.qb;
public class TestClass{
int i;
public int j;
protected int k;
private int l;

Select 2 options

A. Member variable i.
B. Member variable j.
C. Member variable k.
D. Member variable k, but only for subclasses.
E. Member variable l.


Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within!!!

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) ArrayLists (1) Arrays (2) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (52) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (4) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (7) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (11) Java Programmer 2 (8) Javascript Frameworks (1) Java SE Professional (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quizzes (17) references (2) resources (1) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (1) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)