Что будет напечатано, если файл не найден, хотя URL адрес определен правильно?

Какая из строк кода компилируется с ошибкой?

Какие модификаторы можно использовать в строке 5, чтобы код компилировался без ошибок?

Какой результат выполнения следующей программы Вы ожидаете?

Какие результаты компиляции и выполнения фрагмента кода Вы ожидаете?

1. double d1 =-15.5, d2 = 5.0, d3 = 1.0;

2. double result;

3. result=d1%d2;

4. System.out.println("result="+result);

5. result=d1%(d3-1);

6. System.out.println("result="+result);

A. Компиляция и выполнение проходит успешно. Результат: result = 0.5 result=Infinite

B. Компиляция и выполнение проходит успешно. Результат: result = -0.5 result=NaN

C. Компиляция и выполнение проходит успешно. Результат: result = 3.1 result= Infinite

D. Ошибка компиляции в строках 3,5. Деление % не определено для типа double.

E. Исключение ArithmeticException в строке 5. Остаток от деление на нуль.

 

1. public class Craw {

2. static private int flying=10;

3. public static void main(String[] args) {

4. Craw sp1 = new Craw();

5. ++sp1.flying;

6. Craw sp2 = new Craw();

7. sp2.flying++;

8. sp1=null;

9. sp2=null;

10. sp2 = new Craw();

11. sp2.flying++;

12. sp1 = new Craw();

13. ++sp1.flying;

14. ++Craw.flying;

15. System.out.println("flying=" + flying);} }

A. Программа компилируется и выполняется без ошибок. Результат: flying =15.

B. Программа компилируется и выполняется без ошибок. Результат: flying =10.

C. Программа компилируется и выполняется без ошибок. Результат: flying =14.

D. Ошибка компиляции в строках 5, 7, 11, 13. Переменная flying не доступна.

Ошибка компиляции в строке 14. Переменная flying не доступна.

 

1. public class Ancestor {

2. static double calc(double x){return x*x;}

3. }

4. public class Successor extends Ancestor {

5. … … … calc(double x){return ++x*++x;}

6. }

A. static private double calc(double x)

B. static void calc(double x)

C. public double calc(double x)

D. static public double calc(double x)

E. double calc(double x)

F. final public double calc(double x)

 

1. char c1=50,c2=10;

2. short s; int i;

 

A. s=(short)(c1-c2);

B. System.out.println("subtraction="+s);

C. System.out.println("subtraction="+(c1-c2));

D. i=c1-c2;

E. System.out.println("subtraction="+i);

F. c1=(char)c1-c2;

G. System.out.println("subtraction="+(char)c1);

 

8. Какой из методов, членов класса Equivalent, будет вызван в строке 5?

1. class Equivalent{

2. void inform(…){…};

3. public static void main(String[] args) {

4. Equivalent eq=new Equivalent();

5. eq.inform('c');}}

 

A. void inform(short s){System.out.println("Short inform "+s);}

B. void inform(String str){System.out.println("String inform "+str);}

C. void inform(float x){System.out.println("Float inform "+x);}

D. void inform(long i){System.out.println("Long inform "+i);}

 

1. public void init() {

2. AppletContext ac=getAppletContext();

3. URL url1,url;

4. url=getCodeBase();

5. try{

6. url1=new URL(url+"HTML.htm");

7. ac.showDocument(url1);

8. }catch(MalformedURLException e){System.out.println("URL exception");}

9. catch(IOException e){System.out.println("IO exception");}

10. catch(Exception e){System.out.println("General exception");}

11. finally{System.out.println("Finally part");};

12. System.out.println("Carrying on");

13. }

A. Ничего не будет напечатано

B. General exception

C. URL exception

D. IO exception

E. Finally part

F. Carrying on

10. Метод readFile(), может выбрасывать исключения IOException и FileNotFoundException. Как правильно вызывать этот метод?

A).

1. public void call () {

2. try{ bytes = readFile();

3. }catch(FileNotFoundException e){…}

4. catch (EOFException e){…}; }

B).

1. public static void main(String[] args) throws Exception{

2. byte bytes[]= new byte[100];

3. bytes = readFile();

4. for(int i=0;i<100;i++){System.out.println(bytes[i]);};

}

C).

1. public void call () {

2. try{ bytes = readFile();

3. } catch(IOException e){…}

4. catch(FileNotFoundException e){…} }

D).

1. public void call () {

2. try{ bytes = readFile() throw FileNotFoundException ;

3. } catch(IOException e){…} }

5.

E).

1. public static void main(String[] args)throws FileNotFoundException{

2. byte bytes[]= new byte[100];

3. bytes = readFile();

4. for(int i=0;i<100;i++){System.out.println(bytes[i]);};

5. }

 

11. Какие из методов можно поместить в строке 3 класса Polymorph?

1. public class Polymorph {

2. public float method(float a) throws RuntimeException{ return 7.0F;}

3. ???

4. }

A. public float method(float a){return 7.0F;}

B. public int method(float a) throws ArithmeticException{return 7;}

C. private float method(float a) throws NoSuchMethodException{return 7.0F;}

D. public float method(float x,float y) throws NoSuchMethodException{ return 7F;}

E. public String method(float x) throws MalformedURLException {return "OK";}

 

12. Какие из вызовов метода innerMethod(), помещенных в строке 7 приведут к ошибке компиляции?

1. public class Outer {

2. private int x=1;

3. public class Inner{

4. private int y=2;

5. public void innerMethod(){}}

6. public static void main(String[] args){

7. ??? }

8. }

 

A. Outer o=new Outer();Inner i=o.new Inner();i.innerMethod();

B. Outer o=new Outer();Outer.Inner i=o.new Inner();i.innerMethod();

C. Outer o=new Outer();o.new Inner().innerMethod();

D. Outer.Inner i=new Outer().new Inner();i.innerMethod();

E. new Outer().new Inner().innerMethod();

F. Outer.Inner i=new Outer().Inner(); i. innerMethod();