The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes KB question pg 409 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "KB question pg 409" Watch "KB question pg 409" New topic
Author

KB question pg 409

Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
class Mineral{}
class Gem extends Mineral
{}

class Miner
{
static int i =8;
static String s = null;
public static void getWt(Mineral m)
{
int y=0/x;
Sysytem.out.println(s);

public static void main(String a[])
{
Mineral ma[]= {new Mineral(), new Gem()};
for(Object o : ma)
getWt((Mineral) o);

comandline java Miner.java

gives error NoClassDefFoundError

Please explain why??


Thanks<br />Dinesh
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

try "java Miner"


Never ascribe to malice that which can be adequately explained by stupidity.
Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
I tried it worked.
But wht was the reason
Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
if i pass java Miner diamond
what will be the output??
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8717
Hey Dinesh,

What part of the answer in the book was confusing to you?

Ber


Eliminate fossil fuel subsidies. (If you're not on the edge, you're taking up too much room.)
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12956
    
    3

Originally posted by Dinesh Tahiliani:
I tried it worked.
But wht was the reason

The "java" launcher expects a class name (such as "Miner") as the argument. Not the name of a Java source code file ("Miner.java").


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: KB question pg 409
 
Similar Threads
Question from K&B Chapter 5
object reference
Why null null?
BinarySearch
K&B Master Exam SCJP6 class mineral question: why is the answer 'null null'