errors in classes

Im just new to java and need help with this Question. i know the answer is e) and understand how all the ones above it work but i do not understand why it would create an error. thanx.

Consider the following two classes:

class C1

{

private int v1;

private static int v2;

public void setV1 (int val)

{

v1 = val;

}

public static void setV2(int val)

{

v2 = val;

}

}

class C2

{

public static char[] v3={'a','b'};

private int v4;

public C2 (int n)

{

v4 = n;

}

public void m1 (C1 x)

{

x.setV1(5);

}

}

Suppose that the following instructions are used in the main() method in a class Test. Each choice

should be considered independently ?as it if were in its own main() method. Circle the letter of

the statement which causes an error.

a) C1 x = new C1();

x.setV1(6);

b) C2.v3[1] = "c".charAt(0);

c) C2 z = new C2(10);

d) C1.setV2(C2.v3.length);

e) C1 y = new C1();

C2.m1(y);

[1100 byte] By [3807312a] at [2007-11-26 18:56:00]
# 1
Unless I didn't understand something because I can't concentrate on the question anymore:C2.m1(y) would be a call to a static (class) method. Since m1 is not declared to be static, this wil result in a problem - you can't all an object's method without actually having an
CeciNEstPasUnProgrammeura at 2007-7-9 20:34:41 > top of Java-index,Java Essentials,New To Java...
# 2
Before you get jumped with 30 replies of "Do your own homework!", let me say that you should at least attempt to answer the question before dumping it here. Let us know your thought processes and why you think that, then we can tell you if you're right or wrong.
hunter9000a at 2007-7-9 20:34:41 > top of Java-index,Java Essentials,New To Java...
# 3
but if the method m1 isnt declared to be static wouldnt that mean that u can call it from a different class? and isnt y the object here ..?
3807312a at 2007-7-9 20:34:41 > top of Java-index,Java Essentials,New To Java...
# 4

Let us define

public class Example

{

public static void staticFoo() {/*...*/}

public void foo() {/*...*/}

}

Then we can say

Example.staticFoo();

or

Example ex = new Example();

ex.foo();

ex.staticFoo(); // Avoid this, use through class-name instead, as above

but not

Example.foo();

because foo() is not a static (class) method.

#

duckbilla at 2007-7-9 20:34:41 > top of Java-index,Java Essentials,New To Java...