• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

k& B chapter 10 , question 5 and 7

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am first time posting a doubt , i searched for this question but found no post for this

I have doubt regarding the below two questions :


Q-5.
Given the default classpath:

/foo

And this directory structure:

foo
|
test

|
xcom
|--A.class
|--B.java

And these two files:

package xcom;
public class A { }

package xcom;
public class B extends A { }

Which allows B.java to compile? (Choose all that apply.)

Set the current directory to xcom then invoke

javac B.java

Set the current directory to xcom then invoke

javac -classpath . B.java

Set the current directory to test then invoke

javac -classpath . xcom/B.java

Set the current directory to test then invoke

javac -classpath xcom B.java

Set the current directory to test then invoke

javac -classpath xcom:. B.java


(Howcome C is true and B is false( what is the problem B option? ), Please anyone explain me.


Q-7)Given two files:

a=b.java
c_d.class

Are in the current directory, which command-line invocation(s) could complete without error? (Choose all that apply.)

java -Da=b c_d

java -D a=b c_d

javac -Da=b c_d

javac -D a=b c_d


For sure c and d are wrong as we are not allowed to use -D with javac command , i have no doubt regarding the correct answer which is (A).

Now the doubts are that
1)question is saying first one is file ? howcome such name ?
2)Using -D, java -Da=b c_d seems to be very wierd.

Please any one put some light on above also

I am beating my head


Thanks in advance.
Vishal
 
Vishal Chugh
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

May be i have got answer for my 5th question, i went thru classpath topic twice ...

B can't be true as suppose if current directory is xcom , in this case it will try to find xcom directory under current directory (to serach for class file )which is xcom only (obviously there is no issue in finding A.java file)

Please correct me if i am on wrong track

Still not clear with question 7

Thanks
Vishal
 
Vishal Chugh
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I am restarting this thread , please guide for K&B questions in this post...

Thanku
Vishal Chugh
 
Vishal Chugh
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am planning to write SCJP very soon....i am really need of guidance of you all , please help me in these doubt , otherwise this thread will again go down the heap

Thanks
Vishal
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic