




Étudies grâce aux nombreuses ressources disponibles sur Docsity
Gagnz des points en aidant d'autres étudiants ou achete-les avec un plan Premium
Cette page n'est pas visible dans l'aperçu
Ne manques pas les parties importantes!





public class A{ int x ; private int y ; public void A(){ x = ++y ; y = x % y ; } public static void main(String [] args){ System.out.println("x = " + x + ", y = " + y) ; } }
public class A{ private int x ; public float y ; public A(){ System.out.print() ; } } class Main{ public static void main(String [] args){ A a ; a = new A() ; a.x++ ; a.y++ ; System.out.println("x = " + a.x + ", y = " + a.y) ; } }
Question 3 :
class A{ private int x = 2; public float y = 2.0f; public A(){ System.out.print("Objet crée, son Etat est : ") ; } } public class Main{ public static void main(String [] args){ A a = new A() ; a.x ++ ; a.y += a.y ; System.out.println("x = " + a.x + ", a.y = " + y) ; } }
public class A{ public A(){ System.out.print("Objet crée") ; } public static void main(String [] args){ new A() ; } }
public class A{ private char c; public static void init(char c){ this.c = c ; } public A(){ init('5') ; } public static void main(String [] args) { A obj1 = new A() ; System.out.println( obj1.c ) ; }
public class A{ private int x ; private int y ; public A(){ this.x = -1 ; this.y = -1 ; } public A(int x){ this.x = x ; this.y = x ; } public A(int x, int y){ this.x = x ; this.y = y ; } public void affiche(){ System.out.print( x + "," + y + " / ") ; } public static void main(String [] args) { A obj1 = new A() ; A obj2 = new A(5) ; A obj3 = new A(8,9) ; obj1.affiche() ; obj2.affiche() ;
obj3.affiche() ; }
public class A{ private int x = -1 ; private int y = -1 ; public A(int x){ this.x = x ; this.y = x ; } public void affiche(){ System.out.print( x + ", " + y ) ; } public static void main(String [] args) { A obj1 = new A() ; obj1.affiche() ; }
public class A{ private int x = -1 ; public A(int x){ this.x = x ; } public void affiche(){ System.out.print( x ) ; } public static void main(String [] args) { A obj1 = new A(5) ; obj1.A(6) ; obj1.affiche() ; }
Question 16 :
public class A { private static int x ; public A() { x++ ; } public static void main(String [] args) { A obj1 = new A() ; A obj2 = new A() ; A obj3 = new A() ; System.out.print( A.x +","+ obj1.x +","+ obj2.x +","+ obj3.x) ; } }
public class A { private final int x ; public A(int x) { this.x = x ; } public static void main(String [] args) { A obj1 = new A(3) ; A obj2 = new A(4) ; A obj3 = new A(5) ; System.out.print( obj1.x +", "+ obj2.x +", "+ obj3.x) ; } }
public class A { private final int x ; private int y = 1 ; public A(int x) { } }