



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




1 public class Test 2 { 3 private int a; 4 private boolean b; 5 private static int c = 42;
6 public static void main( String[] args ) 7 { 8 Test7 ref = new Test7();
9 ref.method1( 5 ); 10 }
11 public Test7() 12 { 13 a = 1; 14 }
15 public void method1( int x ) 16 { 17 int a = x; 18 int b;
19 b = this.a + 2; 20 this.a = b * 3;
21 System.out.println( "this.a = " + this.a ); 22 System.out.println( "this.b = " + this.b ); 23 System.out.println( "c = " + c ); 24 System.out.println( "b = " + b ); 25 System.out.println( "a = " + a ); 26 System.out.println( "method2() result = " + method2( x + b ) ); 27 System.out.println( "this.a = " + this.a ); 28 System.out.println( "this.b = " + this.b ); 29 }
30 private int method2( int x ) 31 { 32 int a = x; 33 int c = this.a + a;
34 b = a != c;
35 System.out.println( "a = " + a ); 36 System.out.println( "b = " + b ); 37 System.out.println( "c = " + c ); 38 System.out.println( "this.a = " + this.a ); 39 System.out.println( "this.b = " + this.b );
40 this.a = a + 2; 41 this.b = b == false;
42 return x + 3; 43 } 44 }
int x = /* some value */; String str;
if ( x / 2 == 2 ) str = "2 stars"; else if ( x / 2 == 4 ) str = "4 stars"; else if ( x / 2 == 6 ) str = "6 stars"; else str = "a comet";
System.out.println( str );
int mystery( int a ) { int b = a + 3;
if ( b > 5 ) { a = mystery( a - 1 ); System.out.println( a + " " + b ); } else { a = b + 3; System.out.println( a + " " + b ); }
return b; }