aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes simple Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "simple Question" Watch "simple Question" New topic
Author

simple Question

jaysingh solanki
Greenhorn

Joined: Nov 11, 2003
Posts: 14
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

Joined: Dec 22, 2003
Posts: 8
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


SCJP(1.2)
Chetan Mishra
Greenhorn

Joined: Sep 09, 2003
Posts: 8
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

Joined: Nov 11, 2003
Posts: 14
But What if i declare
class as
final class Test{;;;}
 
wood burning stoves
 
subject: simple Question