JAVA试题英文版(答案)

合集下载

经典java面试英文题

经典java面试英文题

1.What is the result when you compile and run the following code?public class Test{public void method(){for(int i=0;i<3;i++){System.out.print(i);}System.out.print(i);}}result: compile error分析:i是局部变量。

for循环完成后,i的引用即消失。

2.What will be the result of executing the following code?Given that Test1 is a class.class Test1{public static void main(String[] args){Test1[] t1 = new Test1[10];Test1[][] t2 = new Test1[5][];if(t1[0]==null){t2[0] = new Test1[10];t2[1] = new Test1[10];t2[2] = new Test1[10];t2[3] = new Test1[10];t2[4] = new Test1[10];}System.out.println(t1[0]);System.out.println(t2[1][0]);}}result:null null分析:new数组后,数组有大小,但值为null3.What will happen when you attempt to compile and run the following code? class Base{int i = 99;public void amethod(){System.out.println("Base.method()");}Base(){amethod();}}public class Derived extends Base{int i = -1;public static void main(String args[]){Base b = new Derived();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("Derived.amethod()");}}result:Derived.amethod()99Derived.amethod()解释:Derived 重写了Base的amethod方法。

绝对经典Java英文笔试题、答案

绝对经典Java英文笔试题、答案
1) if 2) then 3) goto 4) while 5) case
Question 7) Which of the following are legal identifiers
1) 2variable 2) variable2 3) _whatavariable 4) _3_ 5) $anothervar 6) #myvar
Question 2)
What will happen if you try to compile and run the following code
public class MyClass { public static void main(String arguments[]) { amethod(arguments); } public void amethod(String[] arguments) { System.out.println(arguments); System.out.println(arguments[1]); }
1) a sequence of 5 0's will be printed 2) Error: ar is used before it is initialized 3) Error Mine must be declared abstract 4) IndexOutOfBoundes Error
System.out.println(argv[2]); } }
1) myprog 2) good 3) morning 4) Exception raised: "ng.ArrayIndexOutOfBoundsException: 2"
Question 6) Which of the following are keywords or reserved words in Java?

英文java面试题(含答案)

英文java面试题(含答案)

英文java面试题(含答案)1.Tell me a little about yourselfI am holding a master degress in software science and had 2-year work experience in software development. I have used J2EE technology for 2 years,including Jsp,servlet,javabean,XML,EJB,I also used C language for half year and IBM mainframe technology half year and IBM mainframe technology half year.And the projects I participated in follow the Waterfall model lifecycle starting from design,then coding ,testing,maintenance.2.Describe a situation where you had to work under pressure,and explain how you handle it.Once when we did a mainframe project,our customer wanted to see a demo from our team before they signed the contract with our company.It is urgent,because our customer didn t give us enough time to do it. So all my team menbers had to work overtime,but we finished it punctually and perfectly . Our customer was satisfied with it.Actually,It is common to meet some deadlines or work under pressure in IT field.I am ok with it.3.What would your last employer tell me about your work performanceI am sure my last employer will praise my work performance,because he was reluctant to let me go when I told him I want to quit and study abroad,and he said I am welcome to come back when I finish study.4.What is your major weaknessI always want everything to be perfect.Sometimes,I am over-sensitive. When a design pattern or technical solution comes up during a meeting discussion,I am always the first one to test the feasibility.Some leader don t like such person because sometimes it is embarrassing when I prove it doesn t work while the leader still believe it is a perfect solution,But I think I did nothing wrong about it,it is good for the company.5.Why did you leave your last jobAlthough I did well in the last company,I always feel the theoretical study and actual practice are equally important and depend on each other.So,I decide to further study and actual practice are equally important and dependent on each other.So,I decide to further study to extend my theory in computer science.6.What are your strengthsWhat I am superior to others I believe is strong interest in software development I have.Many friends of mine working in IT field are holding bachelor degree or master degree and have worked for several years,but they don t have much interest in it,they only treat what they do everything a job,a means to survive,they don t have career plan at all. I am different. I like writing programs.I have set up my career goal long time ago.I will do my best to make it possible in the future.And I have worked hard towards this goal for several years.7.What are your future career plansI would like to be a software engineer now.but my career goal is to be an excellent software architector in the future.I like writing programs. Software is a kind of art, although sometimes it drove me crazy,after I overcame the difficulties I feel I am useful,I will keep working in IT field.8.What are your salary expectationsI believe your company will set up reasonable salary for me according to my ability,so I don t worry about it at all.Between 7000 to 8000 monthly9. Why are you interested in this position?Your company specializes in providing technical solutionsto customers and the last company I worked in also specializes in this field. I have relevant skills and experiences meeting your requirement.I am sure I can do it well.10.Do you have any questions that you would like to ask meWhat is a typical workday like and what would I doWhat is your expectation for me in this job11.What J2EE design patterns have you used beforeCommand/Session Facade/Service Locator/Data Access Object/Business Delegate。

IBM java 英文面试题(附参考答案)

IBM java 英文面试题(附参考答案)

1.what is oracle.2.what is major differenece oracle8i and oracle9i.4.tell me some thing ur self.5.please tell me about oops.6.what is single inheritance.7.what is multiple inheritance.8.can java support multiple inheritance.9.what is interface.10.what is differenec between abstract class and interface.11.how to u prove that abstrace class cannot instantiate directly.12.what is differenece between string and stringbuffer.13.what is immutable14.how to write a program using sort program.15 how to write a program using unsort program.16.what is legacy.17.what is legacy api18.what is legacy interface.19.what is main difference hashmap and hastable20.what is main difference between arraylist and vector.21.what is struts framework.22.what are distributed techonologies.23.what is advantage and disadvantage of distributed techonologies.24.what is main difference between jsp and servlets.25.what is difference between procedure and functions.26.what is jdbc.27.what are type of drivers.28.what is type 4 driver.29.how to collect requuirements form u r client.30.which process use in ur project.31.what is deployment descriptor.32.what is heirarchy of files in struts.33.please draw struts frame wrok.34.please draw j2ee architecture.35.please draw mvc-2 architecture.36.please draw that how design op module.37.how to find a file on linux.38.how to configure weblogic8.1 on linux.39.why you use struts framework in ur project.40.what is platfrom independent41.what is awt and swing.42.what is heavy wieght components.43.what is feature of weblgoic8.1.44.why you choose application server on linux and database server on aix.45.please tell me about ur project.46.what is major concepts in oops.47.why u choose mvc-2 architecture.48.what is implicit object.49.how many implicit objects in jsp50.why choose weblogic8.1 other than any applicationserver.51.what is water fall model vs sdlc52.what is use of dataflowdiagrams53.wha t is ip in ur project.54.what about reception module—————————————————————————————————————————————————————————1. Oracle is an RDBMS product with DDL and DML from a company called Oracle Inc.2. Difference between 8i and 9i is given in the Oracle site3. Question not available4. Something5. oops is Object Oriented Programming6.what is single inheritance.ans:one class is inherited by only other one class7.what is multiple inheritance.ans:One class inheriting more than one class at atime8.can java support multiple inheritance.ans:No9.what is interface.ans:Interface has only method declarations but no defn10.what is differenec between abstract class and interface.ans:In abstract class some methods may contain definition,but in interface every method should be abstract11.how to u prove that abstrace class cannot instantiate directly.ans:As they dont have constructor they cant be instantiated 12.what is differenece between string and stringbuffer.ans:Strings are immutable where as string buffer can be modified 13.what is immutableans:Which cant be changed14.how to write a program using sort program.15 how to write a program using unsort program.ans: Both can be done using javascriptThis is for Sortfunction SelectTextSort(obj) { // sort by textvar N=obj.options.length;for (var i=0;i<N-1;i++) {for (var j=i+1;j<N;j++) {if ( obj.options[i].text > obj.options[j].text ) {var i1= (obj.options[i].selected == true ) ? true : falsevar j1= (obj.options[j].selected == true ) ? true : falsevar q1 = obj.options[j].text;var q2 = obj.options[j].value;obj.options[j].text = obj.options[i].text;obj.options[j].value = obj.options[i].value;obj.options[i].text = q1;obj.options[i].value = q2;obj.options[i].selected = (j1 && true ) ? true : falseobj.options[j].selected = (i1 && true ) ? true : false}}}return true}16.what is legacy.17.what is legacy api18.what is legacy interface.ans: legacy is something that is old in terms of technology/ system19.what is main difference hashmap and hastableans:Hash table is synchronised20.what is main difference between arraylist and vector.ans:Vector is synchronised21.what is struts framework.22.what are distributed techonologies.distributed technologies means any technology / s/w program that are having many components in multiple environments that interact with each other depending on the functional requirements and design.23.what is advantage and disadvantage of distributed techonologies.overdependance on single platform / single language is avoided. Application can be built flexible to meet requirements. Division of labour is possible. Best of all the technologies andplatforms can be optimally utilized. Complexity of requirements can be reduced.25.what is difference between procedure and functions.'ans:Fuctions can return value ,procedures cant return value26.what is jdbc.ans:Connecting to DB from java program requires JDBC27.what are type of drivers.type1,2,3,429.how to collect requuirements form u r client.is not a job of a technical person. It is better for a BA to do it.30.which process use in ur project.Generally u can say:Project related process: Analysis, Design, Sign-off Documents, Implementation, Integration, Testing, UATWork related process:Technical Design, Work Allocation, Code Review Checklist, Unit Test Form will be prepared by the Project Lead and given to the developer.Developer prepares the Unit Test CaseImplements Code, Performs TestSubmits Code through CVS / VSSSubmits documents along with Release Checklist to the tester / leader.31.what is deployment descriptor.ans:Which contains the infrnmation like which file to be used 40.what is platfrom independentans:A language is said to be platform independent if it can be run on any machine with out modifying code41.what is awt and swing.ans:AWT are heavy weight components and swings are light weight components46.what is major concepts in oops.ans:Abstraction,polymorphism,encapsulation,inheritance47.why u choose mvc-2 architecture.ans:In MVC-2 controller is servlet rather than JSP which makes it efficient48.what is implicit object.ans:Implicit objects are a set of Java objects that the JSP Container makes available to developers in each page49.how many implicit objects in jspans:out,page,session,request,response,application,page context,config。

Java笔试常见英语题(附答案)

Java笔试常见英语题(附答案)

Q1. How could Java classes direct program messages to the system console, but error messages, say to a file?.Java中如何将程序信息导航到系统的console,而把错误信息放入到一个file 中?The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed:Stream st = new Stream(new FileOutputStream("output.txt"));System.setErr(st); System.setOut(st);系统有一个展现标准输出的out变量,以及一个负责标准错误设置的err变量,默认情况下这两个变量都指向系统的console,这就是标准输出如何能被改变方向(就是改变信息的输出位置)。

* Q2. What's the difference between an interface and an abstract class?抽象类和接口的区别:A. An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.抽象类中可能会含有带有方法体的一般方法,而这在接口中是不允许的。

JAVA 英文测试题

JAVA 英文测试题

JAVA Test(30minutes)1.length () Does array has this method? What about string has this method?2.Expressions “switch (exp), write down all the types of exp.3.What's the difference between String and StringBuffer? List some common methods ofthe string and stringbuffer.4.What's the difference between Error and Exception?5.How many basic types does java have? What are the default values? How will a stringconvert to integer?6.What's the difference between INCLUDE in dynamic state and INCLUDE in static stateamong JSP? What's the difference of two jumping methods of JSP?7.What’s the operational principle of Spring?8.What’s work principle of Hibernate? What a dvantage does Hibernate have?9.Write down the complete code that jdbc connect mysql database.10.What’s the difference between Statement and PrepareStatement?11.Translation Test(15minutes)Please translate one of the following paragraphs into Chinese:请选择以下任一段翻译成中文:1.Many powerful Web sites today are built strictly on CGI, and you can in fact do nearlyanything with CGI. However, Web sites built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of response time. The response of a CGI program depends on how much data must be sent, as well as the load on both the server and the Internet. (On top of this, starting a CGI program tends to be slow.) The initial designers of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of applications people developed.2.If Java is, in fact, yet another computer programming language, you may questionwhy it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn’t immediately obvious if you’re coming from a traditional programming perspective. Although Java is very useful for solving traditional standalone programming problems, it is also important because it will solve programming problems on the World Wide Web.12.Written Test(30 minutes)Please write two short essays at least 100words for each one in English.(每篇至少100字)1. What is the biggest IT challenge you have faced and how did you handle it?2. What are you looking for in your next job? What is important to you?。

IBM java 英文面试题(附参考答案)

IBM java 英文面试题(附参考答案)

1.what is oracle.2.what is major differenece oracle8i and oracle9i.4.tell me some thing ur self.5.please tell me about oops.6.what is single inheritance.7.what is multiple inheritance.8.can java support multiple inheritance.9.what is interface.10.what is differenec between abstract class and interface.11.how to u prove that abstrace class cannot instantiate directly.12.what is differenece between string and stringbuffer.13.what is immutable14.how to write a program using sort program.15 how to write a program using unsort program.16.what is legacy.17.what is legacy api18.what is legacy interface.19.what is main difference hashmap and hastable20.what is main difference between arraylist and vector.21.what is struts framework.22.what are distributed techonologies.23.what is advantage and disadvantage of distributed techonologies.24.what is main difference between jsp and servlets.25.what is difference between procedure and functions.26.what is jdbc.27.what are type of drivers.28.what is type 4 driver.29.how to collect requuirements form u r client.30.which process use in ur project.31.what is deployment descriptor.32.what is heirarchy of files in struts.33.please draw struts frame wrok.34.please draw j2ee architecture.35.please draw mvc-2 architecture.36.please draw that how design op module.37.how to find a file on linux.38.how to configure weblogic8.1 on linux.39.why you use struts framework in ur project.40.what is platfrom independent41.what is awt and swing.42.what is heavy wieght components.43.what is feature of weblgoic8.1.44.why you choose application server on linux and database server on aix.45.please tell me about ur project.46.what is major concepts in oops.47.why u choose mvc-2 architecture.48.what is implicit object.49.how many implicit objects in jsp50.why choose weblogic8.1 other than any applicationserver.51.what is water fall model vs sdlc52.what is use of dataflowdiagrams53.wha t is ip in ur project.54.what about reception module—————————————————————————————————————————————————————————1. Oracle is an RDBMS product with DDL and DML from a company called Oracle Inc.2. Difference between 8i and 9i is given in the Oracle site3. Question not available4. Something5. oops is Object Oriented Programming6.what is single inheritance.ans:one class is inherited by only other one class7.what is multiple inheritance.ans:One class inheriting more than one class at atime8.can java support multiple inheritance.ans:No9.what is interface.ans:Interface has only method declarations but no defn10.what is differenec between abstract class and interface.ans:In abstract class some methods may contain definition,but in interface every method should be abstract11.how to u prove that abstrace class cannot instantiate directly. ans:As they dont have constructor they cant be instantiated12.what is differenece between string and stringbuffer.ans:Strings are immutable where as string buffer can be modified 13.what is immutableans:Which cant be changed14.how to write a program using sort program.15 how to write a program using unsort program.ans: Both can be done using javascriptThis is for Sortfunction SelectTextSort(obj) { // sort by textvar N=obj.options.length;for (var i=0;i<N-1;i++) {for (var j=i+1;j<N;j++) {if ( obj.options[i].text > obj.options[j].text ) {var i1= (obj.options[i].selected == true ) ? true : false var j1= (obj.options[j].selected == true ) ? true : false var q1 = obj.options[j].text;var q2 = obj.options[j].value;obj.options[j].text = obj.options[i].text;obj.options[j].value = obj.options[i].value;obj.options[i].text = q1;obj.options[i].value = q2;obj.options[i].selected = (j1 && true ) ? true : falseobj.options[j].selected = (i1 && true ) ? true : false}}}return true}16.what is legacy.17.what is legacy api18.what is legacy interface.ans: legacy is something that is old in terms of technology/ system19.what is main difference hashmap and hastableans:Hash table is synchronised20.what is main difference between arraylist and vector.ans:Vector is synchronised21.what is struts framework.22.what are distributed techonologies.distributed technologies means any technology / s/w program that are having many components in multiple environments that interact with each other depending on the functional requirements and design.23.what is advantage and disadvantage of distributed techonologies.overdependance on single platform / single language isavoided. Application can be built flexible to meet requirements. Division of labour is possible. Best of all the technologies and platforms can be optimally utilized. Complexity of requirements can be reduced.25.what is difference between procedure and functions.'ans:Fuctions can return value ,procedures cant return value26.what is jdbc.ans:Connecting to DB from java program requires JDBC27.what are type of drivers.type1,2,3,429.how to collect requuirements form u r client.is not a job of a technical person. It is better for a BA to do it.30.which process use in ur project.Generally u can say:Project related process: Analysis, Design, Sign-off Documents, Implementation, Integration, Testing, UATWork related process:Technical Design, Work Allocation, Code Review Checklist, Unit Test Form will be prepared by the Project Lead and given to the developer.Developer prepares the Unit Test CaseImplements Code, Performs TestSubmits Code through CVS / VSSSubmits documents along with Release Checklist to the tester / leader.31.what is deployment descriptor.ans:Which contains the infrnmation like which file to be used40.what is platfrom independentans:A language is said to be platform independent if it can be run on any machine with out modifying code41.what is awt and swing.ans:AWT are heavy weight components and swings are light weight components 46.what is major concepts in oops.ans:Abstraction,polymorphism,encapsulation,inheritance47.why u choose mvc-2 architecture.ans:In MVC-2 controller is servlet rather than JSP which makes it efficient48.what is implicit object.ans:Implicit objects are a set of Java objects that the JSP Container makes available to developers in each page49.how many implicit objects in jspans:out,page,session,request,response,application,page context,config。

java考试选择题英文版

java考试选择题英文版

Read the questions carefullyI have tried to make the questions unambiguous (the meaning should be obvious), but make sure you have read what I have written not what you think I might have written. Thus if it says "Classes can be declared with the private modifier ", it means It is possible to declare a class with the private modifier and not that all classes in all situations can be declared as private. Each question may have one or more correct Answers.QuestionsQuestion 1)Which of the following lines will compile without warning or error.1) float f=1.3;2) char c="a";3) byte b=257;4) boolean b=null;5) int i=10;Question 2)What will happen if you try to compile and run the following codepublic class MyClass {public static void main(String arguments[]) {amethod(arguments);}public void amethod(String[] arguments) {System.out.println(arguments);System.out.println(arguments[1]);}}1) error Can't make static reference to void amethod.2) error method main not correct3) error array must include parameter4) amethod must be declared with StringBecause main is defined as static you need to create an instance of the class in order to call any non-static methods.--------------------------------------------------------------------------------Question 3)Which of the following will compile without error要先出现package1) import java.awt.*;package Mypackage;class Myclass {}2) package MyPackage;import java.awt.*;class MyClass{}3) /*This is a comment */package MyPackage;import java.awt.*;class MyClass{}--------------------------------------------------------------------------------Question 4)A byte can be of what size1) -128 to 1272) (-2 power 8 )-1 to 2 power 83) -255 to 2564)depends on the particular implementation of the Java Virtual machine--------------------------------------------------------------------------------Question 5)What will be printed out if this code is run with the following command line?Java myprog good morning;public class myprog{public static void main(String argv[]){System.out.println(argv[2]);}}1) myprog2) good3) morning4) Exception raised: "ng.ArrayIndexOutOfBoundsException: 2" --------------------------------------------------------------------------------Question 6)Which of the following are keywords or reserved (预定义)words in Java?1) if2) then3) goto4) while5) case--------------------------------------------------------------------------------Question 7)Which of the following are legal identifiers(标识符)1) 2variable2) variable23) _whatavariable4) _3_5) $anothervar6) #myvar--------------------------------------------------------------------------------Question 8)What will happen when you compile and run the following code?public class MyClass{static int i;public static void main(String argv[]){System.out.println(i);}}局部变量(在函数内部)必须先初始化,类级别的可以不初始化Class level variables are always initialised to default values. In the case of an int this will be 0. Method level variables are not given default values and if you attempt to use one before it has been initialised it will cause theError Variable i may not have been initialized1) Error Variable i may not have been initialized2) null3) 14) 0--------------------------------------------------------------------------------Question 9)What will happen if you try to compile and run the following code?public class Q {public static void main(String argv[]){int anar[]=new int[]{1,2,3};System.out.println(anar[1]);}}1) 12) Error anar is referenced before it is initialized3) 24) Error: size of array must be defined-------------------------------------------------------------------------------- Question 10)What will happen if you try to compile and run the following code?public class Q {public static void main(String argv[]){int anar[]=new int[5];System.out.println(anar[0]);}}1) Error: anar is referenced before it is initialized2) null3) 04) 5-------------------------------------------------------------------------------- Question 11)What will be the result of attempting to compile and run the following code?abstract class MineBase {abstract void amethod();static int i;}public class Mine extends MineBase {public static void main(String argv[]){int[] ar=new int[5];for(i=0;i < ar.length;i++)System.out.println(ar[i]);}}Any class derived from an abstract class must either define all of the abstract methods or be declared abstract itself.1) a sequence of 5 0's will be printed2) Error: ar is used before it is initialized3) Error Mine must be declared abstract4) IndexOutOfBoundes Error--------------------------------------------------------------------------------Question 12)What will be printed out if you attempt to compile and run the following code ?int i=1;switch (i) {case 0: System.out.println("zero");break;case 1: System.out.println("one");case 2: System.out.println("two");default: System.out.println("default");}1) one2) one, default3) one, two, default4) default--------------------------------------------------------------------------------Question 13)What will be printed out if you attempt to compile and run the following code?int i=9;switch (i) {default: System.out.println("default");case 0: System.out.println("zero");break;case 1: System.out.println("one");case 2: System.out.println("two");}1) default2) default, zero3) error default clause not defined4) no output displayed--------------------------------------------------------------------------------Question 14)Which of the following lines of code will compile without error1) int i=0;if(i) {System.out.println("Hello");}2) boolean b=true;boolean b2=true;if(b==b2) {System.out.println("So true");}3) int i=1;int j=2;if(i==1|| j==2) System.out.println("OK");4) int i=1;int j=2;if(i==1 &| j==2) System.out.println("OK");--------------------------------------------------------------------------------Question 15)What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory?.import java.io.*;public class Mine {public static void main(String argv[]){Mine m=new Mine();System.out.println(m.amethod());}public int amethod() {try {FileInputStream dis=new FileInputStream("Hello.txt");}catch (FileNotFoundException fne) {System.out.println("No such file found");return -1;}catch(IOException ioe) { }finally{System.out.println("Doing finally");}return 0;}}1) No such file found2 No such file found ,-13) No such file found, Doing finally, -14) 0--------------------------------------------------------------------------------Question 16)Which of the following statements are true?1) Methods cannot be overriden to be more private2) static methods cannot be overloadedStatic methods cannot be overriden but they can be overloaded3) private methods cannot be overloaded4) An overloaded method cannot throw exceptions not checked in the base class--------------------------------------------------------------------------------Question 17)What will happen if you attempt to compile and run the following code?class Base {}class Sub extends Base {}class Sub2 extends Base {}public class CEx{public static void main(String argv[]){Base b=new Base();Sub s=(Sub) b;}}1) Compile and run without error2) Compile time Exception3) Runtime Exception--------------------------------------------------------------------------------Question 18)Which of the following statements are true?1) System.out.println( -1 >>> 2);will output a result larger than 10 无符号右移2) System.out.println( -1 >> 2); will output a positive number 输出-13) System.out.println( 2 >> 1); will output the number 14) System.out.println( 1 <<< 2); will output the number 4--------------------------------------------------------------------------------Question 19)What will happen when you attempt to compile and run the following code?public class Tux extends Thread{static String sName = "vandeleur";public static void main(String argv[]){Tux t = new Tux();t.piggy(sName);System.out.println(sName);}public void piggy(String sName){sName = sName + " wiggy";start();}public void run(){for(int i=0;i < 4; i++){sName = sName + " " + i;}}}1) Compile time error2) Compilation and output of "vandeleur wiggy"3) Compilation and output of "vandeleur wiggy 0 1 2 3"4) Compilation and output of either "vandeleur", "vandeleur 0", "vandeleur 0 1" "vandaleur 0 1 2" or "vandaleur 0 1 2 3"--------------------------------------------------------------------------------Question 20)What will be displayed when you attempt to compile and run the following code//Code startimport java.awt.*;public class Butt extends Frame{public static void main(String argv[]){Butt MyBut=new Butt();}Butt(){Button HelloBut=new Button("Hello");Button ByeBut=new Button("Bye");add(HelloBut);add(ByeBut);setSize(300,300);setVisible(true); }}//Code end1) Two buttons side by side occupying all of the frame, Hello on the left and Bye on the right2) One button occupying the entire frame saying Hello3) One button occupying the entire frame saying Bye4) Two buttons at the top of the frame one saying Hello the other saying Bye--------------------------------------------------------------------------------Question 21)What will be output by the following code?public class MyFor{public static void main(String argv[]){int i;int j;outer: for (i=1;i <3;i++)inner: for(j=1; j<3; j++) {if (j==2) continue outer;System.out.println("Value for i=" + i + " Value for j=" +j);}}}1) Value for i=1 Value for j=12) Value for i=2 Value for j=13) Value for i=2 Value for j=24) Value for i=3 Value for j=1--------------------------------------------------------------------------------Question 22)Which statement is true of the following code?public class Agg{public static void main(String argv[]){Agg a = new Agg();a.go();}public void go(){DSRoss ds1 = new DSRoss("one");ds1.start();}}class DSRoss extends Thread{private String sTname="";DSRoss(String s){sTname = s;}public void run(){notwait();System.out.println("finished");}public void notwait(){while(true){try{System.out.println("waiting");wait();}catch(InterruptedException ie){}System.out.println(sTname);notifyAll();}} }1) It will cause a compile time error2) Compilation and output of "waiting"3) Compilation and output of "waiting" followed by "finished"4) Runtime error, an exception will be thrown--------------------------------------------------------------------------------Question 23)Which of the following methods can be legally inserted in place of the comment //Method Here ?class Base{public void amethod(int i) { }}public class Scope extends Base{public static void main(String argv[]){ }//Method Here}1) void amethod(int i) throws Exception {}2) void amethod(long i)throws Exception {}3) void amethod(long i){}4) public void amethod(int i) throws Exception {}--------------------------------------------------------------------------------Question 24)Which of the following will output -4.01) System.out.println(Math.floor(-4.7));2) System.out.println(Math.round(-4.7));3) System.out.println(Math.ceil(-4.7));4) System.out.println(Math.min(-4.7));Options 1 and 2 will produce -5 and option 4 will not compile because the min method requires 2 parameters.--------------------------------------------------------------------------------Question 25)What will happen if you attempt to compile and run the following code?Integer ten=new Integer(10);Long nine=new Long (9);System.out.println(ten + nine);int i=1;System.out.println(i + ten);1) 19 followed by 202) 19 followed by 113) Compile time error4) 10 followed by 1--------------------------------------------------------------------------------Question 26)If you run the code below, what gets printed out?String s=new String("Bicycle");int iBegin=1;char iEnd=3;System.out.println(s.substring(iBegin,iEnd));1) Bic2) ic3) icy4) error: no method matching substring(int,char)--------------------------------------------------------------------------------Question 27)If you wanted to find out where the position of the letter v (ie return 2) in the string s containing "Java", which of the following could you use?1) mid(2,s);2) charAt(2);3) s.indexOf('v');4) indexOf(s,'v');--------------------------------------------------------------------------------Question 28)Given the following declarationsString s1=new String("Hello");String s2=new String("there");String s3=new String();Which of the following are legal operations?1) s3=s1 + s2;2) s3=s1-s2;3) s3=s1 & s2;4) s3=s1 && s2--------------------------------------------------------------------------------Question 29)What is the result of the following operation?System.out.println(4 | 3); 1000111111) 62) 03) 14) 7--------------------------------------------------------------------------------Question 30)public class MyClass1 {public static void main(String argv[]){ }/*Modifier at XX */class MyInner {}}What modifiers would be legal at XX in the above code?1) public2) private3) static4) friend-------------------------------------------------------------------------------- Question 31)What will happen when you attempt to compile and run the following code?public class Holt extends Thread{private String sThreadName;public static void main(String argv[]){Holt h = new Holt();h.go();}Holt(){}Holt(String s){sThreadName = s;}public String getThreadName(){return sThreadName;}public void go(){Holt first = new Holt("first");first.start();Holt second = new Holt("second");second.start();}public void start(){for(int i = 0; i < 2; i ++){System.out.println(getThreadName()+i);try{Thread.sleep(100);}catch(InterruptedExceptione){System.out.println(e.getMessage());} } }}1) Compile time error2) Output of first0, second0, first0, second13) Output of first0, first1, second0, second14) Runtime error--------------------------------------------------------------------------------Question 32)An Applet has its Layout Manager set to the default of FlowLayout. What code would be correct to change to another Layout Manager.1) setLayoutManager(new GridLayout());2) setLayout(new GridLayout(2,2));3) setGridLayout(2,2);4) setBorderLayout();--------------------------------------------------------------------------------Question 33)What will happen when you attempt to compile and run the following code?.class Background implements Runnable{int i=0;public int r un(){while(true){i++;System.out.println("i="+i);} //End whilereturn 1;}//End run}//End class1) It will compile and the run method will print out the increasing value of i.2) It will compile and calling start will print out the increasing value of i.3) The code will cause an error at compile time.4) Compilation will cause an error because while cannot take a parameter of true.--------------------------------------------------------------------------------Question 34)Which of the following statements about this code are true?public class Morecombe{public static void main(String argv[]){Morecombe m = new Morecombe();m.go(new Turing(){});}public void go(Turing t){t.start();}}class Turing extends Thread{public void run(){for(int i =0; i < 2; i++){System.out.println(i); }}}1) Compilation error due to malformed parameter to go method2) Compilation error, class Turing has no start method3) Compilation and output of 0 followed by 14) Compilation but runtime error--------------------------------------------------------------------------------Question 35)What will be the result when you attempt to compile and run the following code?.public class Conv{public static void main(String argv[]){Conv c=new Conv();String s=new String("ello");c.amethod(s);}public void amethod(String s){char c='H';c+=s;System.out.println(c);}}1) Compilation and output the string "Hello"2) Compilation and output the string "ello"3) Compilation and output the string elloH4) Compile time error--------------------------------------------------------------------------------Question 36)Given the following code, what test would you need to put in place of the comment line? //place test hereto result in an output of the string Equalpublic class EqTest{public static void main(String argv[]){EqTest e=new EqTest();}EqTest(){String s="Java";String s2="java";//place test here {System.out.println("Equal");}else{System.out.println("Not equal");}}}1) if(s==s2)2) if(s.equals(s2)3) if(s.equalsIgnoreCase(s2))4)if(s.noCaseMatch(s2))--------------------------------------------------------------------------------Question 37)Given the following codeimport java.awt.*;public class SetF extends Frame{public static void main(String argv[]){SetF s=new SetF();s.setSize(300,200);s.setVisible(true);}}How could you set the frame surface color to pink1)s.setBackground(Color.pink);2)s.setColor(PINK);3)s.Background(pink);4)s.color=Color.pink--------------------------------------------------------------------------------Question 38)How can you change the current working directory using an instance of the File class called FileName?1) FileName.chdir("DirName")2) FileName.cd("DirName")3) FileName.cwd("DirName")4) The File class does not support directly changing the current directory.--------------------------------------------------------------------------------Question 39)If you create a TextField with a constructor to set it to occupy 5 columns, what difference will it make if you use it with a proportional font (ie Times Roman) or a fixed pitch typewriter style font (Courier).1)With a fixed font you will see 5 characters, with a proportional it will depend on the width of the characters2)With a fixed font you will see 5 characters,with a proportional it will cause the field to expand to fit the text3)The columns setting does not affect the number of characters displayed4)Both will show exactly 5 characters--------------------------------------------------------------------------------Question 40)Given the following code how could you invoke the Base constructor that will print out the string "base constructor";class Base{Base(int i){System.out.println("base constructor"); }Base(){ }}public class Sup extends Base{public static void main(String argv[]){Sup s= new Sup();//One }Sup() { //Two }public void derived() { //Three }}1) On the line After //One put Base(10);2) On the line After //One put super(10);3) On the line After //Two put super(10);4) On the line After //Three put super(10);--------------------------------------------------------------------------------Question 41)Given the following code what will be output?public class Pass{ static int j=20;public static void main(String argv[]){ int i=10; Pass p = new Pass(); p.amethod(i);System.out.println(i); System.out.println(j); }public void amethod(int x){ x=x*2; j=j*2; }}1) Error: amethod parameter does not match variable2) 20 and 403) 10 and 404) 10, and 20--------------------------------------------------------------------------------Question 42)What code placed after the comment //For loop would result in the population of every element of the array ia[] with a value from variable i.?public class Lin{ public static void main(String argv[]){ Lin l = new Lin(); l.amethod(); }public void amethod(){ int ia[] = new int[4]; //Start For loop{ ia[i]=i; System.out.println(ia[i]);}}}1) for(int i=0; i < ia.length() -1; i++)2) for (int i=0; i< ia.length(); i++)3) for(int i=1; i < 4; i++)4) for(int i=0; i< ia.length;i++)--------------------------------------------------------------------------------Question 43)What will be the result when you try to compile and run the following code?private class Base{Base(){int i = 100;System.out.println(i);}}public class Pri extends Base{static int i = 200;public static void main(String argv[]){Pri p = new Pri();System.out.println(i);}}1) Error at compile time2) 2003) 100 followed by 2004) 100--------------------------------------------------------------------------------Question 44)What will the following code print out?public class Oct{public static void main(String argv[]){ Oct o = new Oct(); o.amethod(); }public void amethod(){int oi= 012; System.out.println(oi);}}1)122)0123)10 8*1 + 8^0 * 2 = 104)10.0--------------------------------------------------------------------------------Question 45)You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique.What interface might be most suitable to meet this need?1)Set (集合)2)List3)Map4)Vector--------------------------------------------------------------------------------Question 46)Which of the following will successfully create an instance of the Vector class and add an element?1) Vector v=new Vector(99);v[1]=99;2) Vector v=new Vector();v.addElement(99);3) Vector v=new Vector();v.add(99);4 Vector v=new Vector(100);v.addElement("99");--------------------------------------------------------------------------------Question 47)You have created a simple Frame and overridden the paint method as followspublic void paint(Graphics g){g.drawString("Dolly",50,10);}What will be the result when you attempt to compile and run the program?1) The string "Dolly" will be displayed at the centre of the frame2) An error at compilation complaining at the signature of the paint method3) The lower part of the word Dolly will be seen at the top of the frame, with the top hidden.4) The string "Dolly" will be shown at the bottom of the frame.--------------------------------------------------------------------------------Question 48)Given the following codeimport java.io.*;public class Th{public static void main(String argv[]){Th t = new Th();t.amethod(); }public void amethod(){try{ioCall();}catch(IOException ioe){}}}What code would be most likely for the body of the ioCall method1) public void ioCall ()throws IOException{DataInputStream din = new DataInputStream(System.in);din.readChar(); }2) public void ioCall ()throw IOException{DataInputStream din = new DataInputStream(System.in);din.readChar();}3) public void ioCall (){DataInputStream din = new DataInputStream(System.in);din.readChar(); }4)public void ioCall throws IOException(){DataInputStream din = new DataInputStream(System.in);din.readChar(); }--------------------------------------------------------------------------------Question 49)Which of the following can you perform using the File class?1) Change the current directory2) Return the name of the parent directory3) Access a random file4) Find if a file contains text or binary information--------------------------------------------------------------------------------Question 50)You are using the GridBagLayout manager to place a series of buttons on a Frame. You want to make the size of one of the buttons bigger than the text it contains. Which of the following will allow you to do that?1) The GridBagLayout manager does not allow you to do this2) The setFill method of the GridBagLayout class3) The setFill method of the GridBagConstraints class4) The fill field of the GridBagConstraints class--------------------------------------------------------------------------------。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

一.Which two demonstrate an “is a” relationship? (Choose Two)A. public interface Person { }//语法错了public class Employee extends Person { }B. public interface Shape { }//语法错了public class Employee extends Sha pe { }C. public interface Color { }//语法错了public class Employee extends Color { }D. public class Species { }public class Animal{private Species species;}E. interface Component { }Class Container implements Component (Private Component[ ] children;二.which statement is true?A. An anonymous inner class may be declared as finalB. An anonymous inner class can be declared as privateC. An anonymous inner class can implement mutiple interfacesD. An anonymous inner class can access final variables in any enclosing scope (不能)E. Construction of an instance of a static inner class requires an instance of the encloing outer class构造一个静态的内部类对象需要构造包含它的外部类的对象三. Given:1. package foo;2.3. public class Outer (4.public static class Inner (5.)6. )Which statement is true?A. An instance of the Inner class can be constructed with “new Outer.Inner ()”B. An instance of the inner class cannot be constructed outside of package foo他们都是public的,只要在外部import就行C. An instance of the inner class can only be constructed from within the outerclassD. From within the package bar, an instance of the inner class can be constructed with “new inner()”四.Exhibit(展览、陈列):1 public class enclosinggone{2 public class insideone{}3 }4 public class inertest{5 public static void main (String[] args){6 enclosingone eo = new enclosingone();7 //insert code here8 }}Which statement at line 7 constructs an instance of the inner class?A. InsideOne ei = eo.new InsideOne(); 写程序试出来B. Eo.InsideOne ei = eo.new InsideOne();C InsideOne ei = EnclosingOne.new InsideOne();D.EnclosingOne InsideOne ei = eo.new InsideOne();五.1)interface Foo{2)int k=0;3)}4) public class Test implements Foo{5)public static void main(String args[]){6)int i;7) Test test =new Test();8)i=test.k;9)i=Test.k;10)i=Foo.k;11)}12) }What is the result?A. Compilation succeeds.B. An error at line 2 causes compilation to fail.C. An error at line 9 causes compilation to fail.D. An error at line 10 causes compilation to fail.E. An error at line 11 causes compilation to fail.六.//point Xpublic class Foo{public static void main(String[] args){PrintWriter out=new PrintWriter(newjava.io.OutputStreamWriter(System.out),true);out.println("Hello");}}which statement at point X on line 1 allows this code to compile and run?在point X这个位置要填入什么代码才能使程序运行A.import java.io.PrintWriterB.include java.io.PrintWriterC.import java.io.OutputStreamWriterD.include java.io.OutputStreamWriterE.No statement is needed本来两个都要import,但是后者OutputStreamWriter指定了包结构java.io.OutputStreamWriter七.what is reserved words in java? 保留字而非关键字A. runB.defaultC. implementD. import八. which three are valid declaraction of a float?(float作为整数是可以的,其余几个都是double)A. float foo=-1;B. float foo=1.0;C. float foo=42e1;D. float foo=2.02f;E. float foo=3.03d;F. float foo=0x0123;九.Given:8.int index = 1;9.boolean[] test = new boolean[3]; (数组作为对象缺省初始化为false)10. boolean foo= test [index];What is the result?A. foo has the value of 0B. foo has the value of nullC. foo has the value of trueD. foo has the value of falseE. an exception is thrownF. the code will not compile十. Given:1. public class test(2. public static void main(String[]args){3. String foo = args [1];4. String foo = args [2];5. String foo = args [3];6. }7. }And the command line invocation:Java TestWhat is the result?A. baz has the value of “”B. baz has the value of nullC. baz has the value of “red”D. baz has the value of “blue”E. bax has the value of “green”F. the code does not compileG. the program throws an exception(此题题目出错了,重复定义了变量foo,如果没有重复的话,应选G,因为只传递了0-2三个数组元素,而题目中需要访问args [3],所以会抛出数组越界异常)十一.int index=1;int foo[]=new int[3];int bar=foo[index]; //bar=0int baz=bar+index; //baz=1what is the result?A. baz has a value of 0B. baz has value of 1C. baz has value of 2D. an exception is thrownE. the code will not compile十二.1)public class Foo{2)public static void main(String args[]){3)String s;4)System.out.println("s="+s);5)}6)}what is the result?A. The code compiles and “s=” is printed.B. The code compiles and “s=null” is printed.C. The code does not compile because string s is not initialized.D. The code does not compile because string s cannot be referenced.E. The code compiles, but a NullPointerException is thrown when toString is called.十三. Which will declare a method that forces a subclass to implement it?(谁声明了一个方法,子类必须实现它)A. public double methoda();B. static void methoda (double d1) {}C. public native double methoda();D. abstract public void methoda();E. protected void methoda (double d1){}十四.You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access modifier that will accomplish this objective? (你希望子类在任何包里都能访问父类,为完成这个目的,下列哪个是最严格的访问权限)A. PublicB. PrivateC. ProtectedD. TransientE. No access modifier is qualified十五. Given:1. abstract class abstrctIt {2. abstract float getFloat ();3. )4. public class AbstractTest extends AbstractIt {5. private float f1= 1.0f;6. private float getFloat () {return f1;}7. }What is the result?A. Compilation is successful.B. An error on line 6 causes a runtime failure.(抛出实时异常)C. An error at line 6 causes compilation to fail.D. An error at line 2 causes compilation to fail.(子类覆盖父类方法的时候,不能比父类方法具有更严格的访问权限)十六. Click the exhibit button:1. public class test{2. public int aMethod(){3.static int i=0;4. i++;5. return I;6. }7. public static void main (String args[]){8. test test = new test();9. test.aMethod();10. int j = test.aMethod();11. System.out.printIn(j);12. }13. }(局部变量不能声明为静态)What is the result?A. Compilation will fail.B. Compilation will succeed and the program will print “0”.C. Compilation will succeed and the program will print “1”.D. Compilation will succeed and the program will print “2”.十七.1)class Super{2)public float getNum(){return 3.0f;}3)}4)5)public class Sub extends Super{6)7)}which method, placed at line 6, will cause a compiler error?A. public float getNum(){return 4.0f;}B. public void getNum(){} 返回值类型不同不足以构成方法的重载C. public void getNum(double d){}D. public double getNum(float d){return 4.0d;}十八. Which declaration prevents creating a subclass of an outer class?A.static class FooBar{}B.pivate class Foobar{}C.abstract class FooBar{}D.final public class FooBar{}E.final abstract class FooBar{} 抽象类不能声明为final十九. byte[] array1,array2[]byte array3[][]byte[][] array4if each has been initialized, which statement will cause a compile error?A. array2 = array1;B. array2 = array3;C. array2 = array4;D. both A and BE. both A and CF. both B and C(一维数组和二维数组的区别)二十.class Super{public int i=0;public Super(String text){i=1;}}public class Sub extends Super{public Sub(String text){i=2;}public static void main(String args[]){Sub sub=new Sub("Hello");System.out.println(sub.i);}}what is the result?A. compile will failB. compile success and print "0"C. compile success and print "1"D. compile success and print "2"子类总要去调用父类的构造函数,有两种调用方式,自动调用(无参构造函数),主动调用带参构造函数。

相关文档
最新文档