Get the entire book!
Java for the Beginning Programmer

1. Is there anything wrong with the following class?

public class MyClass
{
  public void test()
  {
    System.out.println("Test");
  }
  
  public static void main(String args[])
  {
    test();
  }
}

2. What will be the output of this program? Why?

public class MyClass
{
  public static void test(int i)
  {
    i = i + 1;
  }
  
  public static void main(String args[])
  {
    int i = 10;
    test(i);
    System.out.println("i is " + i );
  }
}

3. What is the effect of placing the keyword “static” in front of a local variable?

4. Do the terms class and object mean the same thing? If not, what is the difference.

5. Can the main method access instance variables directly?


Copyright 2005 - 2010 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright and trademark information.