Set 3

Multiple Choice Question

QID: 
437

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

QID: 
436

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

QID: 
435

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

QID: 
434

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

QID: 
433

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.

Pages

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) Arrays (1) 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) (55) 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 (5) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (9) 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 (7) Javascript Frameworks (1) Java SE Professional (1) JPA 1 - Module (6) JPA 1 - Modules (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) Quartz Scheduler (1) Quizzes (17) RabbitMQ (1) references (2) 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 (3) 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)