Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java homework Use the following partial classes for the next seven questions. Th

ID: 3673454 • Letter: J

Question

Java homework

Use the following partial classes for the next seven questions. The four classes below are in the same package (and directory).

public class Class1 {

public String a;
private String b;
protected String c;

...

}

public class Class2 extends Class1 {

protected String x;
private String y;
public String z;

...

}

public class Class3 extends Class2 {

private String q;
protected String r;
public String s;

...

}

public class Class4 {

...

}

QUESTION 1

Which variables can be directly accessed from within Class1?

Select one or more:

1. a

2. b

3. c

4. x

5. y

6. z

7. q

8. r

9. s

QUESTION 2

Which variables can be directly accessed from within Class2?

Select one or more:

1. a

2. b

3. c

4. x

5. y

6. z

7. q

8. r

9. s

QUESTION 3

Which variables can be directly accessed from within Class4?

Select one or more:

1. a

2. b

3. c

4. x

5. y

6. z

7. q

8. r

9. s

QUESTION 4

Which of the following is true about Class4?

Select one:

a. it has no parent class

b. it has one parent class

c. it has more than one parent class

d. you cannot tell anything about the parent of Class4 from the code shown

QUESTION 5

The two classes below are in a different package (and directory) than Class1, Class2, Class3, and Class4.

public class Class5 {

...

}

public class Class6 extends Class3

...

}

Which variables can be directly accessed from within Class5?

1. a

2. b

3. c

4. x

5. y

6. z

7. q

8. r

9. s

Question 6

Which variables can be directly accessed from within Class6?

Select one or more:

1. a

2. b

3. c

4. x

5. y

6. z

7. q

8. r

9. s

Explanation / Answer

Concept: http://www.tutorialspoint.com/java/java_access_modifiers.htm

1. a, b, c, x, z, r, s. Instance variable of any access priviledge can be accessed within their own class.

2. a, c, x, y, z, r, s. a and c are inherited from class 1. x, y, z are instance variables. r and s are protected.

3. a, c, x, z, r, s.

4. It has one parent class. Every class in java inherits from Object class.

5. a, z, s. Because they are public.

6. a, c, x, z, r, s. All inherited from each other up the chain.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote