Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple Question

 
jaysingh solanki
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code:
class Test {
int count;
public void write()
{
System.out.println("number of count"+count);
}
public static void main(String arg[])
{ Test t=new Test();
t.write();//ok
System.out.println(t3.write());//line1
}
}
Q1: -If the method return value then we get output atline1
but in the case when the method is void and if we try to do this
in line1:Incompatible for mehtod can't convert void to char[]
what it means.//end
Q2:Accessibility modifier
If no Accessibility modifier is given
to class and members then they accessible
for classes in the same package and subclass.
 
P S Arora
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println(t3.write());//line1
It will give u a compilation error.
System.out.println expects char[] , string , double,int ,boolean ,etc as parameters while t.write() returns nothing and therefore it is not able to find out any method which takes void as the arguement
 
Chetan Mishra
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Originally posted by jaysingh solanki:
.....
Q2:Accessibility modifier
If no Accessibility modifier is given
to class and members then they accessible
for classes in the same package and subclass.

When no accessibility modifier is specified, classes are visible and accessible to Onlysame package members and not subclasses.
Regards,
Chetan
"Pick battles big enough to matter, small enough to win"
 
jaysingh solanki
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But What if i declare
class as
final class Test{;;;}
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic