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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Asking you the two problems:" Watch "Asking you the two problems:" New topic
Author

Asking you the two problems:

Tu Ran
Ranch Hand

Joined: Feb 09, 2002
Posts: 30
package Base;
class Base{
protected void amethod(){
System.out.println("amethod");
}}
class Class1 extends Base{
public static void main(String argv[]){
Base b = new Base();
b.amethod();
}
}//Why it can compile but throw a "NoClassDefFoundErro"

second:
In the SCJP examination,whether it should need us to different from reserved words
and key words or not :
if it demanded,please tell me what are the keywords,and what are reserved
words in SCJP examination?
Thanks a lot~~
[ February 23, 2002: Message edited by: Tu Ran ]

Enjoy java,enjoy life
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
1. What is the stack trace exactly? What is command line you use to run the program? Sounds like a classpath problem to me...
Try going into the directory Base and type:
java -classpath . Base.Class1
or if you are in directory Base you can type
java -classpath .. Base.Class1
let me know
2. Keywords have been heavily discussed in the following threads:
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=014367
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=014586
[ February 23, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Holmes Wong
Ranch Hand

Joined: Feb 18, 2002
Posts: 163
I ran your code, and no problem with it. The problem is probably with your class path. Did
you run your code inside package or outside it?
Jian Yi
Ranch Hand

Joined: Feb 01, 2002
Posts: 127
Hi Valentin & Holmes,
Do I have to create Base directory and move the .class files to Base dir by my own? Is there a way to get it done automatically? Since javac doesn't create Base dir for you even though we specify the package as Base in our java file.
Thanks,
Jenny
Holmes Wong
Ranch Hand

Joined: Feb 18, 2002
Posts: 163
I think you cannot automatically generate a package specified by you from my understanding.
What if you have many files in one package? You must move all these files inside this package if
packane name for these files are specified on the first line of your code. Unless you do not specify, then you will have a default package that is your current directory.

Originally posted by Jenny Yin:
Hi Valentin & Holmes,
Do I have to create Base directory and move the .class files to Base dir by my own? Is there a way to get it done automatically? Since javac doesn't create Base dir for you even though we specify the package as Base in our java file.
Thanks,
Jenny
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Asking you the two problems:
 
Similar Threads
Inheritance/Polymorphism question
SCJP problem with boxing
scjp
Nested Interface?? in SCJP 1.4
Inheritance