Új hozzászólás Aktív témák

  • filomena98

    friss újonc

    Kedves Mindenki!
    Van itt valaki, aki tudna segíteni kiválasztani a helyes válaszokat? Már napok óta rágódom rajtuk, de eddig csak arra jutottam, hogy már nem vagyok biztos semmiben. :D

    1. Melyik a helyes allitas?
    class MyClass{
    static MyClass ref;
    String[] arguments;
    public static void main(String[] args){
    ref = new MyClass;
    ref.func(args);
    }
    public void func(String[] args){
    ref.arguments = args;
    }
    }
    A-nem kompilalhato, mert a statikus main metodus nem hivhat nem statikus matodust, mint a func
    B-a program kompilalhato, es hiba nelkul mukodik
    C-kompilalhato, de inditas utan hibat dob ki(exception)
    D-nem kompilalhato, mert az args parametert a statikus main metodbol, nem lehet tovabbitani nem statikus metodusnak, mint a func
    2.
    Van egy osztalyunk aminek Book a neve.Az alabbiak kozul melyik a helyesen deklarant konstruktor?
    A- public static void Book(String[] args){}
    B-Book Book(){}
    C-void Book(){}
    D-egyik sem
    3.
    Melyik konstruktor helyezheto a 11. sorba, hogy ne legyen gond a kompilacional?
    Class MySuper{
    int number;
    MySuper(int i){ number = i;}
    }
    class MySub extends MySuper{
    int count;
    MySub(int count,int num){
    super(num);
    this.count=count;
    }
    //ide kell kivalasztani a megfelelo konstruktort
    }
    A-MySub(int count){this(count, count);}
    B-MySub(int count){super(count); this(count,0);}
    C-MySub(int count){this.count=count; super(count);}
    4.Melyik parameter deklaraciot lehet hasznalni a masodik sorban?
    public class Testing{
    //itt
    public long getNum(String name){
    Long number = accounts.get(name);
    return number == null ? 0 : number;
    }
    public void setNum(String name, long number){
    accounts.put(name,number);
    }
    }
    A- private Map<String,Long> accounts = new HashMap<String,Long>();
    B-private Map<String<Long>> accounts = new HashMap<String<Long>>();
    C-private Map<String, long> accounts = new HashMap<String,long>();
    D-private Map accounts = new HashMap();
    E-private Map<String,Long> accounts = new Map<String,Long>();
    5. Melyikallitas helyes?
    class Fruit{}
    class Apple extends Fruit{}
    public class TestApp{
    public static void main(String[] args){
    List<? extends Apple> lst1 = new ArrayList<Fruit>();
    List<? extends Fruit>lst2 =new ArrayList<Apple>();
    List<? super Apple> lst3 = new ArrayList<Fruit>();
    List? super Fruit> lst4 = new ArrayList<Apple>();
    List<?> lst5 = lst1;
    List<?> lst6=lst3;
    List lst7 = lst6;
    List<?> lst8 = lst7;
    }
    }
    A- a 9. sor kompilalhato, a 10. nem
    B- a 7. sor kompilalhato, a 8. nem
    C- egyik valasz sem helyes
    D- 5. sor kompilalhato, a 6. nem
    E-a 11. sor kompilalhato, a 12 . nem
    6. Hol van a hiba a kodban?
    public class MyClass{
    public static void main(String[] args) throws A{
    try{
    f();
    }finally{
    System.out.println("Done.");
    }catch(A e){
    throw e;
    }
    }
    public static void f() throws B{
    throw new B();
    }
    }
    class A extends Throwable{}
    class B extends A{}
    A-a mainbe throw A helyett throw B kell
    B-mainben a finally blocknak a catch block utan kell kovetkeznie
    C-try block utan nem lehet egyszerre finally es catch block is
    D-a main metodban, a catch blokban, A e helyett B e kellene
    E-az A osztaly deklaracioja nem helyes
    7. Mit ir ki a program inditas utan?
    public class MyClass{
    public static void main(String[] args) throws InterruptedException{
    try{
    f();
    System.out.println("1");
    }finally{
    System.out.println("2");
    }
    System.out.println("3");
    }
    static void f() throws InterruptedException{
    throw new InterruptedException("Time to go home.");
    }
    }
    A- 2 es 3
    B- 1 es 2
    C- 2 es InterruptedExceptiont jelez
    D-1, 2 es 3
    E-3 es 2
    F-1 es 3
    8.Mi lesz az eredmeny futtatas utan?
    public class MyClass{
    public static void main(String[] args){
    C c = new C();
    System.out.println(c.max(13,20));
    }
    }
    class A{
    int max( int x, int y){ if( x>y) return x; else return y;
    }
    class B extends A{
    int max(int x,int y){ return super.max(y,x)-10;}
    }
    class C extends B {
    int max (int x, int y) { return super.max(x+10, y+10);}
    }
    A-a kod nem kompilalhato, mert nem egyertelmu a max() metodus hivasa
    B- a kod kompilalhato, inditas utan 23-at ir ki
    C-nem kompilalhato, mert a max () metodus a B osztalybanrossz sorrendben kuldi az argumenteket
    D-kompilalhato,13-et ir ki
    E-kompilalhato 29-et ir ki
    F-kompilalhato, 39-et ir ki

Új hozzászólás Aktív témák

Hirdetés