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

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

1. char c1=50,c2=10;

2. short s; int i;

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

B. i=c1-c2;

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

D. c1=(char)c1-c2;

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

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

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

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(long i){System.out.println("Long inform "+i);}

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

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

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

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. URL exception

B. IO exception

C. General exception

D. Finally part

E. Carrying on

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

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

A).

1. public void call () {

2. try{ bytes = readFile();

3. }catch(FileNotFoundException e){…}

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

B).

1. public void call () {

2. try{ bytes = readFile();

3. } catch(IOException e){…}

4. catch(FileNotFoundException e){…} }

C).

1. public void call () {

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

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

D).

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]);};

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 x,float y) throws NoSuchMethodException{ return 7F;}

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

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

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

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.Inner i=new Outer().Inner(); i. innerMethod();

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

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

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


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: