java高级软件工程师面试题(3)

2019-01-19 17:07

int i,ia[10],ib[10]; /*第一行*/ for (i=0;i<=9;i++) /*第2行*/ ia[i]=0; /*第3行*/ ib=ia; /*第4行*/

下述程序代码中有语法错误的行是( )。 int i,ia[10],ib[10]; /*第一行*/ for (i=0;i<=9;i++) /*第2行*/ ia[i]=0; /*第3行*/ ib=ia; /*第4行*/ a.第1行 b.第2行 c.第3行 d.第4行 5:

what will be the result of executing the following code? // filename; superclassx.java package packagex; public class superclassx {

protected void superclassmethodx() { }

int superclassvarx; }

// filename subclassy.java 1.package packagex.packagey; 2.

3.public class subclassy extends superclassx 4.{

5.superclassx objx = new subclassy(); 6.subclassy objy = new subclassy(); 7.void subclassmethody() 8.{

9.objy.superclassmethodx(); 10.int i;

11.i = objy.superclassvarx; 12.} 13.} choices:

what will be the result of executing the following code? // filename; superclassx.java package packagex; public class superclassx {

protected void superclassmethodx() { }

int superclassvarx; }

// filename subclassy.java 1.package packagex.packagey; 2.

3.public class subclassy extends superclassx 4.{

5.superclassx objx = new subclassy(); 6.subclassy objy = new subclassy(); 7.void subclassmethody() 8.{

9.objy.superclassmethodx(); 10.int i;

11.i = objy.superclassvarx; 12.} 13.} choices:

a.compilation error at line 5 b.compilation error at line 9

c.runtime exception at line 11 d.none of these

6:which are not java keywords? a.true b.const c.super d.void

7: consider the class hierarchy shown below:

—————————————————————————————————— class fourwheeler implements drivingutilities class car extends fourwheeler class truck extends fourwheeler class bus extends fourwheeler class crane extends fourwheeler

——————————————————————————————————— consider the following code below: 1.drivingutilities du; 2.fourwheeler fw;

3.truck mytruck = new truck(); 4.du = (drivingutilities)mytruck; 5.fw = new crane(); 6.fw = du;

which of the statements below are true? choices:

a.line 4 will not compile because an interface cannot refer to an object. b.the code will compile and run.

c.the code will not compile without an explicit cast at line 6, because going down the hierarchy without casting is not allowed.

d.the code will compile if we put an explicit cast at line 6 but will throw an exception at runtime. 8:exhibit :

1. public class test ( 2. private static int j = 0;

3.

4. private static boolean methodb(int k) ( 5. j += k; 6. return true; 6. ) 7.

8. public static void methoda(int i) { 9. boolean b:

10. b = i < 10 | methodb (4); 11. b = i < 10 || methodb (8); 12. ) 13.

14. public static void main (string args[] } ( 15. methoda (0);

16. system.out.printin(j); 17. ) 18. )

what is the result? a.the program prints “0” b.the program prints “4” c.the program prints “8” d.the program prints “12” 9:

public class outerclass { private double d1 = 1.0; //insert code here }

you need to insert an inner class declaration at line 3. which two inner class declarations are valid?

public class outerclass { private double d1 = 1.0; //insert code here

}

you need to insert an inner class declaration at line 3. which two inner class declarations are valid?

a.class innerone{ public static double methoda() {return d1;} } b.public class innerone{ static double methoda() {return d1;} } c.private class innerone{ double methoda() {return d1;} }

d.static class innerone{ protected double methoda() {return d1;} } 10:

the following code is entire contents of a file called example.java,causes precisely one error during compilation: class subclass extends baseclass{ }

class baseclass(){ string str; public baseclass(){

system.out.println(“ok”);} public baseclass(string s){ str=s;}}

public class example{ public void method(){

subclass s=new subclass(“hello”); baseclass b=new baseclass(“world”); } }

which line would be cause the error?

the following code is entire contents of a file called example.java,causes precisely one error during compilation: class subclass extends baseclass{ }

class baseclass(){ string str; public baseclass(){


java高级软件工程师面试题(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:高三英语上学期第二次月考试题17

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: