|
1. Care vor fi valorile variabilelor a, b si c dupa executia secventei de mai jos ? int a = 0, b = 1, c = (++a >= b-- ? a++ : ++b);
| |
|
2. Care va fi valoarea variabilei tip dupa executia secventei alaturate ?
|
int c = (int)'b'; String tip = "nimic"; switch (c) { case 'a'-'z': tip = "litera"; case '0'-'9': tip = "cifra"; break; default : tip = "altceva"; } |
|
3. Ce se va īntāmpla la executia secventei alaturate ?
|
int test = 0, infinit=0; try { infinit=1/0; test ++; } catch(Exception e) { test ++; } finally { test ++; } System.out.println("test=" + test + " infinit=" + infinit); |
|
4. Ce va afisa la executie aplicatia CtorDemo?
|
class A { int a=1; A() { a=2;} } class B extends A { int b=3; B() { b=a;} } public class CtorDemo { public static void main(String args[]) { B bobj = new B(); System.out.println(bobj.b); } } |
|
5. In ce conditii putem apela o metoda de sortare polimorfica unei colectii formata din obiecte de acelasi tip ?
| |
|
6. Sa consideram declaratiile alaturate. Care dintre urmatoarele variante nu este corecta ?
|
class A { static int x=37; transient int y=47; static void f() { A aref = this; int i=x; int j=y; g(); } void g() { } } |
|
7. Sa consideram declaratiile alaturate de clase si interfete. Care din acestea nu este corecta ?
|
interface Test {} abstract class AbstractImpl implements Test {} class TestImpl extends AbstractImpl {} |
|
8. Ce se va afisa la executia urmatoarei secvente de cod: RuntimeException a = new RuntimeException(); System.out.println(a.getClass().getSuperclass().getSuperclass());
| |
|
9. Ce puteti spune despre aplicatia TestImpl?
|
public class TestImpl { public static void main(String args[]) { HelloImpl h1= new HelloImpl(), h2=h1; h1.message = "Salut"; System.out.println(h2.sayHello()); } } interface Hello { String sayHello(); } class HelloImpl implements Hello{ static String message = "Hello"; String sayHello() { return message; } } |
|
10. Ce īntelegeti prin serializare ?
| |