关键词不能为空

当前您在: 主页 > 英语 >

中国民航信息网络股份有限公司JAVA面试题和笔试题

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-08 16:36
tags:

-

2021年2月8日发(作者:多听)


QUESTION NO: 4


Given:


1. interface Animal {


2. void soundOff();


3. }


4.


5. class Elephant implements Animal {


6. public void soundOff() {


7. n(



Trumpet



);


8. }


9. }


10.


11. class Lion implements Animal {


12. public void soundOff() {


13. n(

< br>“


Roar



);


14. }


15. }


16.


17. class Alpha1 {


18. static Animal get( String choice ) {


19. if ( IgnoreCase(



meat eater



)) {


20. return new Lion();


21. } else {


22. return new Elephant();


23. }


24. }


25. }


Which compiles?


A. new Animal().soundOff();


B. Elephant e = new Alpha1();


C. Lion 1 = (



meat eater



);


D.



new Alpha1().get(



veggie



).soundO ff();





QUESTION NO: 7


1. class Super {


2. public float getNum() { return 3.0f; }


3. }


4.


5. public class Sub extends Super {.


7. }


Which method, placed at line6, causes compilation to fail?


A.



public void getNum() { }


B. public void getNum(double d) { }


C. public float getNum() { return 4.0f; }


D. public double getNum(float d) { return 4.0d; }





QUESTION NO:14


Given:


1. public class OuterClass {


2. private double d1 = 1.0;


3. // insert code here


4. }


Which two are valid if inserted at line 3? (Choose two)


A. static class InnerOne {


public double methoda() { return d1; }


}


B. static class InnerOne {


static double methoda() { return d1; }


}


C.



private class InnerOne {


public double methoda() { return d1; }


}


D. protected class InnerOne {


static double methoda() { return d1; }


}


E.



public abstract class InnerOne {


public abstract double methoda();


}





QUESTION NO: 16


Given:


1. interface Beta {}


2.


3. class Alpha implements Beta {


4. String testIt() {


5. return



Tested



;


6. }


7. }


8.


9. public class Main1 {


10. static Beta getIt() {


11. return new Alpha();


12. }


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


14. Beta b = getIt();


15. n( () );


16. }


17. }


What is the result?


A. Tested


B.



Compilation fails.


C. The code runs with no output.


D. An exception is thrown at runtime.





QUESTION NO: 23


Given:


1. // Point X


2. public class foo {


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


4. riter out = new riter(


5. new StreamWriter(), true);


6. n(



Hello



);


7. }


8. }


Which statement at Point X on line 1 is required to allow this code to compile?


A.



No statement is required.


B. import .*;


C. include .*;


D. import riter;


E. include riter;





QUESTION NO: 24


Which two are valid declarations of a float? (Choose two)


A.



float f = 1F;


B. float f = 1.0.;


C.



float f =



1



;


D. float f =



1



;


E. float f = 1.0d;





QUESTION NO: 27


Exhibit:


1. public class Mycircle {


2. public double radius;


3. public double diameter;


4.


5. public void setRadius(double radius)


6. = radius;


7. er= radius * 2;


8. }


9.


10. public double getRadius() {


11. return radius;


12. }


13. }


Which statement is true?


A. The Mycircle class is fully encapsulated


(完全封装)


.


B.



The diameter of a given MyCircle is guaranteed to be twice its radius.


C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation.


D. The radius of a MyCircle object can be set without affecting its diameter.





QUESTION NO: 4


1. public class Delta {


2. static boolean foo(char c) {


3. (c);


4. return true;


5. }


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


7. int i =0;


8. for ( foo(



A


< br>); foo(



B



)&&(i<2); foo(



C

< p>


)){


9. i++


10. foo(



D



);


12. }


13. }


14. }


What is the result?


ABDCBDCB





QUESTION NO: 6


Given:


1. public class Test {


2. public static String output =


””


;


3.


4. public static void foo(int i) {


5. try {


6. if(i==1) {


7. throw new Exception();


8. }


9. output +=



1



;


10. }


11. catch(Exception e) {


12. output +=



2



;


13. return;


14. }


15. finally {


16. output +=



3



;


17. }


18. output +=



4



;


19. }


20.


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


22. foo(0); 134


23. foo(1);23


24.


25. }


26. }


What is the value of the variable output at line 23?


13423





QUESTION NO: 7


Given:


1. public class X {


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


3. try {


4. badMethod();


5. (



A



);


6. }


7. catch (Exception ex) {


8. (



B



);


9. }


10. finally {


11. (



C



);


12. }


13. (



D



);


14. }


15. public static void badMethod() {}


17. }


What is the result?


ACD





QUESTION NO: 10


Given:


11. String a =



ABCD



;


12. String b = rCase();


13. e(



a



,



d



);


14. e(



b



,



c



);


15. n(b);


What is the result?


abcd


问答



-


-


-


-


-


-


-


-



本文更新与2021-02-08 16:36,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/615641.html

中国民航信息网络股份有限公司JAVA面试题和笔试题的相关文章

中国民航信息网络股份有限公司JAVA面试题和笔试题随机文章