Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Confused about a Java question

Options
  • 23-07-2010 3:32pm
    #1
    Registered Users Posts: 1,552 ✭✭✭


    Topic title: The assertion mechanism in Java
    Suppose you want to enable assertions for a class named "DemoApp" that is located in the C:\Java\samples directory. The class references various system classes that need to be tested. Which command would you use to enable assertions for the class?

    Choose an option.

    1: C:\>java -ea Java.samples.DemoApp
    2: C:\>java -ea Java.samples.DemoApp...
    3: C:\>java -esa -ea DemoApp
    4: C:\>java -esa -ea:Java.samples.DemoApp

    Now I thought the correct answer would be option 4 but apparently the correct answer is option 3.
    The question doesn't state that the class is an application.
    I don't understand how that can be correct could it be a mistake?
    This is from a Java course.
    Can someone help me understand this?


Comments

  • Registered Users Posts: 1,998 ✭✭✭lynchie


    Answer 4 would be correct if the full package name of DemoApp was Java.samples.DemoApp but as they stated that the class was just called "DemoApp" then answer 3 is correct.

    But.. and somebody else correct me if Im wrong, but technically the answer is none of them as answer 3 would give a ClassNotFoundException as running the command from c:\> like the answers given above would need -cp c:\java\samples added to it?


  • Registered Users Posts: 1,916 ✭✭✭ronivek


    The assumption here is that C:\Java\samples is contained in the Java classpath environment variable I guess. Not that I'm advocating this type of question as being a good gauge of someones ability to do anything other than memorise command line arguments you'll likely never use; I suppose it might highlight if you understand the classpath mechanism enough to arrive at the right answer.


Advertisement