0% found this document useful (0 votes)
20 views1 page

5 - PDFsam - 8. OOPs PDF

The document contains sample questions and answers from a SCJP certification exam preparation material. It includes two questions about Java concepts like constructors, inheritance and access modifiers. The first question tests knowledge of constructor calls and title initialization. The second question is about resolving access issues in a subclass.

Uploaded by

ROHIT JAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

5 - PDFsam - 8. OOPs PDF

The document contains sample questions and answers from a SCJP certification exam preparation material. It includes two questions about Java concepts like constructors, inheritance and access modifiers. The first question tests knowledge of constructor calls and title initialization. The second question is about resolving access issues in a subclass.

Uploaded by

ROHIT JAIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

DURGA’s SCJP Material

D. Instance variables can be used when creating a has-a relationship.


Answer: A, D

Q: 07 Given:
10: public class Hello {
11: String title;
12: int value;
13: public Hello() {
14: title += " World";
15: }
16: public Hello(int value) {
17: this.value = value;
18: title = "Hello";
19: Hello();
20: }
21: }
and:
30: Hello c = new Hello(5);
31: System.out.println(c.title);
What is the result?
A. Hello
B. Hello World
C. Compilation fails.
D. Hello World 5
E. The code runs with no output.
F. An exception is thrown at runtime.
Answer: C

Q: 08 Given:
1. class Super {
2. private int a;
3. protected Super(int a) { this.a = a; }
4. }
...
11. class Sub extends Super {
12. public Sub(int a) { super(a); }
13. public Sub() { this.a = 5; }
14. }
Which two, independently, will allow Sub to compile? (Choose two.)
A. Change line 2 to:
public int a;
B. Change line 2 to :protected int a;
C. Change line 13 to :public Sub() { this(5); }
D. Change line 13 to :public Sub() { super(5); }
E. Change line 13 to :public Sub() { super(a); }
Answer: C, D

DURGASOFT, # 202,2nd Floor,HUDA Maitrivanam,Ameerpet, Hyderabad - 500038,  040 – 64 51 27 86,


80 96 96 96 96, 9246212143 | www.durgasoft.com Page 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy