几个问题?(100分)

  • 主题发起人 dingfuhai
  • 开始时间
D

dingfuhai

Unregistered / Unconfirmed
GUEST, unregistred user!

----------------------------------------------------------
1.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]);
}
}
A) myprog
B) good
C) morning
D) Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"
* Answer:[ ]
----------------------------------------------------------
2.Which of the following are not java reserved words
A) if
B) then

C) goto
D) while
E) case

* Answer:[ ]
----------------------------------------------------------
3.What will happen when you compile the following code
public class MyClass
{
static int i;
public static void main(String argv[])
{
System.out.println(i);
}
}

A) Error Variable i may not have been initialized
B) null
C) 1
D) 0

* Answer:[ ]
----------------------------------------------------------
4.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]);
}
}
A) 1
B) Error anar is referenced before it is initialized
C) 2
D) Error size of array must be defined

* Answer:[ ]
----------------------------------------------------------
5.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]);
}
}
A) Error: anar is referenced before it is initialized
B) null
C) 0
D) 5

* Answer:[ ]
----------------------------------------------------------
6.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);
}
}
A) a sequence of 5 0's will be printed
B) Error: ar is used before it is initialized
C) Error Mine must be declared abstract
D) IndexOutOfBoundes Error i

* Answer:[ ]
----------------------------------------------------------
7.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");
}
A) one
B) one, default
C) one, two, default
D) default

* Answer:[ ]
----------------------------------------------------------
8.What will be printed out if you attempt to compile and run the following
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");
}
A) default
B) default, zero
C) error default clause not defined
D) no output displayed

* Answer:[ ]
----------------------------------------------------------
9.Which of the following lines of code will compile without error
A) int i=0;
if(i)
{
System.out.println("Hello");
}
B) int i=1;
int j = 2;
if(i ==1|| j==2)
System.out.println("OK");

C) int i=1;
int j = 2;
if(i ==1 &amp;| j==2)
System.out.println("OK");

* Answer:[ ]
----------------------------------------------------------
10.What will be output if you try to compile and run the following code and and 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;
}
}
A) No such file found
B) No such file found ,-1
C) No such file found,do
ing finally, -1
D) 0
* Answer:[ ]
 
全是鸟语,没看懂,我的鸟语不好,帮不了你了
 
没学过JAVA,不过做的很认真,呵呵,得几分啊?如果及格就马上开始学。
A
C
A
C
A
C
A
D
B
D
 
wokao,老兄.你让我考java认证,是不是.是不是有证书发.
 
D
C
D
C
C
C
C
B
B
C
 
A
C
D
C
A
C
C
C
A
C
 
d
c
d
c
c
c
c
b
b
c
 
接受答案了.
 

Similar threads

W
回复
5
查看
197
wait_for_love
W
回复
13
查看
139
夜游神宾
回复
8
查看
201
小猪
I
回复
6
查看
176
I
顶部