java開發工程師模擬試題2017
Java 平台是基於 Java 語言的平台。這樣的平台目前非常流行,因此微軟公司推出了與之競爭的平台以及模仿 Java 的' C#語言。下面是小編收集的關於java開發工程師模擬試題,希望大家認真閲讀!
h statement about the garbage collection mechanism are true?
age collection require additional program code in cases where multiple threads are running.
programmer can indicate that a reference through a local variable is no longer of interest.
programmer has a mechanism that eXPlicit and immediately frees the memory used by Java objects.
garbage collection mechanism can free the memory used by Java Object at expectable time.
garbage collection system never reclaims memory from objects while are still Accessible to running user threads.
2. Give the following method:
1)public void method( ){
2) String a,b;
3) a=new String(“hello world”);
4) b=new String(“game over”);
5) tln(a+b+”ok”);
6) a=null;
7) a=b;
tln(a);
9) }
In the absence of compiler optimization, which is the earliest point the object a referred is definitely hand to be garbage collection.
A. before line 3 re line 5 C. before line 6 re line 7 E. Before line 9
3. Which statement about listener is true?
component allow multiple listeners to be added.
multiple listener be add to a single component, the event only affected one listener.
onent don’t allow multiple listeners to be add.
listener mechanism allows you to call an addXXXListener method as many times as is needed, specifying as many different listeners as your design require.
the following code:
public class Example{
public static void main(String args[] ){
int l=0;
do{
tln(“Doing it for l is:”+l);
}while(--l>0)
tln(“Finish”);
}
}
Which well be output:
A. Doing it for l is 3B. Doing it for l is 1C. Doing it for l is 2
D. Doing it for l is 0E. Doing it for l is –1F. Finish
5. Give the code fragment:
1)switch(x){
2) case 1: tln(“Test 1”);break;
3) case 2:
4) case 3: tln(“Test 2”);break;
5) default: tln(“end”);
6) }
which value of x would cause “Test 2” to the output:
A. 1B. 2C. 3D. default
6. Give incompleted method:
1)
2){if(unsafe()){//do something…}
3)else if(safe()){//do the other…}
4)}
The method unsafe() will throw an IOException, which completes the method of declaration when added at line one?
ic IOException methodName()
ic void methodName()
ic void methodName() throw IOException
ic void methodName() throws IOException
ic void methodName() throws Exception
7. Give the code fragment:
if(x>4){
tln(“Test 1”);}
else if (x>9){
tln(“Test 2”);}
else {
tln(“Test 3”);}
Which range of value x would prodUCe of output “Test 2”?
A. x<4B. x>4C. x>9D. None
8. Give the following method:
public void example(){
try{
unsafe();
tln(“Test1”);
}catch(SafeException e){tln(“Test 2”);
}finally{tln(“Test 3”);}
tln(“Test 4”);
Which will display if method unsafe () run normally?
A. Test 1B. Test 2C. Test 3D. Test 4
9. Which method you define as the starting point of new thread in a class from which new the thread can be execution?
A. public void start()B. public void run()C. public void int()
D. public static void main(String args[])E. public void runnable()
n the following class definition:
class A{
protected int i;
A(int i){
this.i=i;
}
}
which of the following would be a valid inner class for this class?
Select all valid answers:
A. class B{
}
s B extends A{
}
s B extends A{
B(){tln(“i=”+i);}
}
s B{
class A{}
}
s A{}
11. Which modifier should be applied to a method for the lock of object this to be oBTained prior to execution any of the method body?
A. synchronizedB. abstractC. finalD. staticE. public
12. The following code is entire contents of a file called ,causes precisely one error during compilation:
1)class SubClass extends BaseClass{
2) }
3)class BaseClass(){
4) String str;
5) public BaseClass(){
6) tln(“ok”);}
7) public BaseClass(String s){
str=s;}
9)}
10)public class Example{
11) public void method(){
12) SubClass s=new SubClass(“hello”);
13) BaseClass b=new BaseClass(“world”);
14) }
15) }
Which line would be cause the error?
A. 9B. 10C. 11D.12
13. Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?
A. String [] aB. String a[]C. char a[][]D. String a[50]F. Object a[50]
14. Give the following java source fragment:
//point x
public class Interesting{
//do something
}
Which statement is correctly Java syntax at point x?
A. import .*;age mypackage;C. static int PI=3.14
D. public class MyClass{//do other thing…}E. class MyClass{//do something…}
15. Give this class outline:
class Example{
private int x;
//rest of class body…
}
Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of ?
A. change private int x to public int xB. change private int x to static int x
C. change private int x to protected int xD. change private int x to final int x
16. A class design requires that a member variable should be accessible only by same package, which modifier Word should be used?
A. protectedB. publicC. no modifierD. private
17. Which modifier should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?
18. Which is corrected argument of main() method of application?
A. String argsB. String ar[]C. Char args[][]D. StringBuffer arg[]
19. “The Employee object is a Person, An Employee has appointment store in a vector, a hire date and a number of dependent”
short answer: use shortest statement declare a class of Employee.
20. Give the following class definition inseparate source files:
public class Example{
public Example(){//do something}
protected Example(int i){//do something}
protected void method(){//do something}
}
public class Hello extends Example{//member method and member vari
-
2017年Java程序員面試題及答案
Sun認證Java程序員考試內容涉及Java所有相關知識、編程概念及applet開發技巧。以下是關於Java程序員面試題及答案,希望大家認真閲讀!第一,談談final,finally,finalize的區別。final?修飾符(關鍵字)如果一個類被聲明為final,意味着它不能再派生出新的子類,不能作為父...
-
Sun推出的Java認證指南
sun公司名稱的由來很多人不知道,它其實是斯坦福大學校園網(StanfordUniversityNetwork)的首字母縮寫。下面是小編整理的Sun推出的Java認證指南,歡迎大家參考!Sun推出的專業認證包括下列三種:◆JAVA認證考試對於JAVA程序設計員,Sun推出兩項認證:SunCertifiedJAVAPro...
-
Java日誌系統框架的設計與實現
在Java領域,存在大量的日誌組件,open-open收錄了21個日誌組件。日誌系統作為一種應用程序服務,對於跟蹤調試、程序狀態記錄、崩潰數據恢復都有着重要的作用,我們可以把Java日誌系統看作是必不可少的跟蹤調試工具。1.簡介日誌系統是一種不可或缺的跟蹤調試工具,特別...
-
Sun目前的軟件策略
作為Sun一直執行的開源其整個中間件軟件產品包戰略的組成部分,Sun將發佈JavaEnterpriseSystem的下一代組件。Sun將通過互聯網上的OpenJava門户項目把SunJavaSystemPortalServer7(系統門户服務器第7版)中的所有組件和技術發佈出來。一開始,Sun將創建一個開源Portl...