Java

  1. Home
  2. Computing & Technology
  3. Java
photo of Paul Leahy

Paul's Java Blog

By Paul Leahy, About.com Guide to Java

Monday's Programming Question

Monday September 8, 2008

Each Monday I’m going to post a question for you to answer. It’s a good way to see if you’ve been paying attention whilst reading some of the articles on this site. What I hope it will also do is extend your knowledge and comfort level with Java.

This week it’s a runtime error question. Here’s a piece of code that has been saved in a file called JollyMessage.java :

// A jolly message is written to the screen!
class Jollymessage
{

   public static void main(String[] args) {

     //Write the message to the terminal window
     System.out.println("Ho Ho Ho!");

   }
}

The above code will produce a runtime error message. That’s to say, a mistake has been made but it won’t be picked up when the program is compiled, only when it is run. What is the mistake and what error will be returned when the compiled code is executed?

Try and see if you can find the error by just looking at the code. I’ll post the answer on Sunday.

If you need a hint, take a look at the creating your first java program article.

Comments

September 8, 2008 at 2:02 pm
(1) Jose Ayerdis says:

So damm easy why don’t you put a real Challenge. I won’t give the obvious Answer but it has to do with “JollyMessage.java” named.

September 8, 2008 at 2:06 pm
(2) João says:

Wrong case in the name of the class… it should be JollyMessage and not Jollymessage.

I suppose that this error, and correct me if I am wrong, should be a Classloader Error.

Some file systems are case sensitive and some are not, maybe this situation arises from some assumption to support both.

September 9, 2008 at 12:14 am
(3) Jose Ayerdis says:

That’s exacly the error…. good job

September 9, 2008 at 3:01 am
(4) mohana priya says:

just i got the class loader Exception

September 12, 2008 at 2:29 am
(5) Paul Leahy says:

Yep, well done everyone.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Discuss

Community Forum

Explore Java

About.com Special Features

Java

  1. Home
  2. Computing & Technology
  3. Java

©2009 About.com, a part of The New York Times Company.

All rights reserved.