Do java programms after giving compilation error generates the .class file?!_NEWLINE_!Do any outer class may have the private as access modifier?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ruby_India
Posted On:   Thursday, July 19, 2001 09:49 AM

If someone asks you that -do any program in java after giving a compilation error gives the .class file -do any class except(inner class) be defined as private or static or protected or abc or xxx Now type the following program ____________________________ private class test { public static void main(String s[]) { System.out.println("Hello!How are You!!"); } } ________________________ -Compile it.... You must have received this error test.java:1:The type type can't be private. Package members are always accessible within the current package. private class test ^ 1 error ____________    More>>

If someone asks you that
-do any program in java after giving a compilation error gives the .class file
-do any class except(inner class) be defined as private or static or protected or abc or xxx

Now type the following program
____________________________
private class test
{
public static void main(String s[])
{
System.out.println("Hello!How are You!!");
}
}
________________________

-Compile it....
You must have received this error

test.java:1:The type type can't be private. Package members are always accessible within the current package.
private class test
^
1 error

____________

Here please notify that compiler has given the error not the warning therfore .class file should not be created but now type
___________

>dir *.class
___________

and you will see that the test.class file existing in the directory
nevertheless this .class file is executable. if you will type
__________________
>java test

it will wish you Hello! and suerly asks you that How are You!!

__________________

You can test it with the following as acces modifiers and the progrm will run Ofcourse it will give you compilation error.
protected
xxx
abc
xyz
private
...
...


Do you have any justification?

   <<Less
About | Sitemap | Contact