Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

JAVA Programming :: Packages

Home > JAVA Programming > Packages > Discussion

6. What is the output for the below code ?

1. public class D {
2. int i;
3. int j;
4. public D(int i,int j){
5. this.i=i;
6. this.j=j;
7. }
8. public void printName() {
9. System.out.println("Name-D");
10. }
11. }
12. public class Test{ 13. public static void main (String[] args){
14. D d = new D();
15. d.printName();
16. }
17. }

Answer: Option B

Explanation :

Since there is already a constructor in this class (public D(int i,int j)), the compiler won't supply a default constructor. If you want a no-argument constructor to overload the with arguments version you already have, you have to define it by yourself. The constructor D() is undefined in class D. If you define explicit constructor then default constructor will not be available. You have to define explicitly like public D(){ } then the above code will work. If no constructor into your class , a default constructor will be automatically generated by the compiler.

Post Your Answer Here:     

Name *
Email
Alert me

No Discussion on this question yet!