java show and describe the output of the followingprograms a 1 public class midterm1 5122002
JAVA Show and describe the output of the followingprograms
A.
1. public class Midterm1 {
2. private static int x = 1;
3. public Midterm1(int x ) {
4. this.x = x ;
5. }
6. public static void main(String[] args) {
7. Midterm1 t1 = new Midterm1(5) ;
8. System.out.println(“x’s value is :”+x );
9. System.out.println(“x’s value is :”+t1.x );
10. }
11. }
B.
1. public class Midterm1 {
2. private static int x = 1;
3. public static void main(String[] args) {
4. int x = 5;
5. method1();
6. System.out.printf(” X’s value is %d%n”, x);
7. method2();
8. System.out.printf(” X’s value is %d%n”, x);
9. }
10. public static void method1 () {
11. int x = 25;
12. ++x;
13. System.out.printf(” X’s value is %d%n”, x);
14. }
15. public static void method2() {
16. x *= 10;
17. System.out.printf(” X’s value is %d%n”, x);
18. }
19. } . . .