Search This Blog

Thursday, February 10, 2011

SCJP 6 Question 28:

Which of these must be true if you execute the following command?
java –classpath xyz hello.my.App
Choose at least one answer.
a. The definition of the App class must be preceded by the statement 'package hello.my;'
b. The definition of the App class must be preceded by the statement 'package xyz.hello.my;'
c. The definition of the App class must be preceded by the statement 'package my;'
d. App.class must be found in xyz\hello\my directory
e. App.class must be found in xyz\hello directory
f. App.class must be found in xyz directory
Answer : A & D
The class path tells SDK tools and applications where to find third-party and user-defined classes -- that is, classes that are not Java extensions or part of the Java platform. The class path needs to find any classes you've compiled with the javac compiler -- its default is the current directory to conveniently enable those classes to be found. So from the above statement we can infer that package hello.my is present in xyz folder.
Package hello.my creates two folders hello and my  (inside hello). This is the hierarchy followed by the packages. So based on the above explanations only A&D are correct.
SocialTwist Tell-a-Friend
SCJP 6 Question 28:SocialTwist Tell-a-Friend

No comments:

Post a Comment