07.01.2015 Views

Opgaver

Opgaver

Opgaver

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.3 Java<br />

Opgave 2.3.1<br />

Betragt følgende Java-program:<br />

public class classfield<br />

{<br />

public static void main( String args[] )<br />

{<br />

B.method1(); // (1)<br />

B.method3(); // (2)<br />

B.method5(); // (3)<br />

B.method6(); // (4)<br />

B instance = new B();<br />

}<br />

}<br />

instance.method1(); // (5)<br />

instance.method3(); // (6)<br />

instance.method5(); // (7)<br />

instance.method6(); // (8)<br />

public class A<br />

{<br />

public static int x = 42;<br />

public int y = 43;<br />

public void method1()<br />

{<br />

x = 52;<br />

}<br />

public void method2()<br />

{<br />

y = 53;<br />

}<br />

public static void method3()<br />

{<br />

x = 62;<br />

}<br />

public static void method4()<br />

22

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!