File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes can someone explain? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "can someone explain?" Watch "can someone explain?" New topic

can someone explain?

jinn, boy

Joined: May 08, 2001
Posts: 8
hi all...
the answer to the question below is 1.
What will happen when you attempt to compile and run this code?
private class Base{}
public class Vis{
transient int iVal;
public static void main(String elephant[]){
1) Compile time error: Base cannot be private
2) Compile time error indicating that an integer cannot be transient
3) Compile time error transient not a data type
4) Compile time error malformed main method
can someone explain why class Base cannot be private.? can i not compile this with the file name also.. isnt anything wrong with the main method also?
Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
Only Inner class can be declared as private, protected,public or default. Outer class can only be public or default. Thats why A.1 is right.
Also you can't compile it other than the file name Because the public class is Vis and the file name has to be same as the public class name.
The main method signature is ok. I didn't find anything wrong with that. Did you ?

Nazmul<br />SCJP,SCWCD,IBM OOAD with UML
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

Welcome to the JavaRanch! Please adjust your displayed named to meet the JavaRanch Naming Policy. Your name should be at least two words seperated by a space. Preferrably your real name. You can change your displayed name here.
Thanks! and Welcome to the JavaRanch!
I agree. Here's the link:
subject: can someone explain?
It's not a secret anymore!