Which class has a default constructor?

Given:
<code>
class X {}
class Y {Y () {}}
class Z {z(int i ) {} }
</code>
Which class has a default constructor?

Given:

class X {}
class Y {Y () {}}
class Z {z(int i ) {} }

Which class has a default constructor?

A.
X only

B.
Y only

C.
Z only

D.
X and Y

E.
Y and Z

F.
X and Z

G.
X, Y and Z



Leave a Reply 9

Your email address will not be published. Required fields are marked *


Marin R

Marin R

The correct answer is A. X only

Since class Z has defined constructor Z(int), it won’t have default constructor

Alex

Alex

I think so, but be careful since there’s written zed in lowercase! I guess is a typo because in any case , so defined, it could not be a valid method.

Kalil Peixoto

Kalil Peixoto

I understand you Alex, but i guess it’s really A. It’s complicated, it depends how well is written on the test so it gets easier to solve it.

Ahmed Galal

Ahmed Galal

I’m agree with Marin R.

if the constructor z small it will not compile as a function.

Nalin

Nalin

Hey Right answer is F.X and Z
please see carefully class Z, the z is in small case so it treat as method not as constructor if you right z(int i){} it gives error return type of method is missing

so right answer is X and Z

Martin Lee

Martin Lee

Hi, I have passed OCAJP 7 (1Z0-803) EXAM with 98%. I would like to share my exam experience with those who are going to take this exam. I learned the Mala Gupta’s book and PassLeader 1Z0-803 dumps. They were describing and explaning the key points of the exam very clearly. To be honest, I read Mala Gupta’s book mainly because of the interest how the basic things in Java are handled internally and I started to take the PassLeader 1Z0-803 dumps (http://www.passleader.com/1z0-803.html), around one week before the exam. Good luck to future Oracle exam takers!

noir

noir

A default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.