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

7 - PDFsam - 8. OOPs

The document discusses Java concepts related to classes, interfaces, inheritance and polymorphism. It provides two questions with multiple choice answers about class constructors and interface implementation. The key points are: 1) The first question asks about a superclass constructor being called from a subclass constructor using super(). The answer is that 420 would be output. 2) The second question provides an interface hierarchy and a class implementing an interface. It asks about the result of the implementation, with the correct answer being that compilation would succeed. 3) Overall the document covers fundamental OOP concepts tested in Java certification exams through example questions and answers.

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)
15 views1 page

7 - PDFsam - 8. OOPs

The document discusses Java concepts related to classes, interfaces, inheritance and polymorphism. It provides two questions with multiple choice answers about class constructors and interface implementation. The key points are: 1) The first question asks about a superclass constructor being called from a subclass constructor using super(). The answer is that 420 would be output. 2) The second question provides an interface hierarchy and a class implementing an interface. It asks about the result of the implementation, with the correct answer being that compilation would succeed. 3) Overall the document covers fundamental OOP concepts tested in Java certification exams through example questions and answers.

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

car has Wheels < ==================> class A{


List <B> b;
}

Mini is a Car < ==================> class A


extends B{ }

Car is an Object < ==================> class A { }

Q: 10 Given:
1. class ClassA {
2. public int numberOfInstances;
3. protected ClassA(int numberOfInstances) {
4. this.numberOfInstances = numberOfInstances;
5. }
6. }
7. public class ExtendedA extends ClassA {
8. private ExtendedA(int numberOfInstances) {
9. super(numberOfInstances);
10. }
11. public static void main(String[] args) {
12. ExtendedA ext = new ExtendedA(420);
13. System.out.print(ext.numberOfInstances);
14. }
15. }
Which statement is true?
A. 420 is the output.
B. An exception is thrown at runtime.
C. All constructors must be declared public.
D. Constructors CANNOT use the private modifier.
E. Constructors CANNOT use the protected modifier.

Answer: A

Q: 11 Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod(){}
6. }
7. class E extends D implements C {
8. public void aMethod(){}
9. public void bMethod(){}
10. public void cMethod(){}
11. }
What is the result?

A. Compilation fails because of an error in line 3.


B. Compilation fails because of an error in line 7.

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


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

You might also like