• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wht would be out put of the programm

 
Akhilesh Yadav
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class C {
public static void main(String [] args){
new C();
}
public C(int x){
System.out.println( " " + (x*2));
}
public C(long x) {

System.out.println("" +x);

}
public void C(){
System.out.println("no");

}

}
 
Arno Reper
Ranch Hand
Posts: 286
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
the output ll be...compiler error no C() constructor found ( or something like that)
arno
 
Arno Reper
Ranch Hand
Posts: 286
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ps : public void C() isn't a constructor...its just a bad idea to use a method with the same name as the class/constructor...
arno
 
Chandrasekhar Mangipudi
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiletime Error occurs in the program. Because user defined Empty
constructor must be defined in the program to avoid compile time error.
 
Joshua Smith
Ranch Hand
Posts: 193
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you remove the void keyword from the snippet below...



...then you'll have a no-args constructor and it will compile.

Josh
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic