public class ParentUtil
{
public int x = 420;
protected int doStuff() { return x; }
}
package testpkg.p2;
import testpkg.p1.ParentUtil;
public class ChildUtil extends ParentUtil
{
public static void main(String [] args)
{
new ChildUtil().callStuff();
}
void callStuff()
{
System.out.print("this " + this.doStuff() ); /* Line 18 */
ParentUtil p = new ParentUtil();
System.out.print(" parent " + p.doStuff() ); /* Line 20 */
}
}
下列说法正确的是:
{
public static void main(String args[])
{
/* Missing code? */
}
public void run() {}
}
下列哪种方法可以启动线程?
yield()
wait()
notify()
notifyAll()
sleep(1000)
aLiveThread.join()
Thread.killThread()
int i = l, j = -1;
switch (i)
{
case 0, 1: j = 1; /* Line 4 */
case 2: j = 2;
default: j = 0;
}
System.out.println("j = " + j);
程序的输出是?
{
public static void main(String[] args)
{
System.out.println("value =" + switchIt(4));
}
public static int switchIt(int x)
{
int j = 1;
switch (x)
{
case l: j++;
case 2: j++;
case 3: j++;
case 4: j++;
case 5: j++;
default: j++;
}
return j + x;
}
}
程序的输出是?
{
public static void throwit ()
{
System.out.print("throwit ");
throw new RuntimeException();
}
public static void main(String [] args)
{
try
{
System.out.print("hello ");
throwit();
}
catch (Exception re )
{
System.out.print("caught ");
}
finally
{
System.out.print("finally ");
}
System.out.println("after ");
}
}
程序的输出是?
{
public A(int x){}
}
class B extends A { }
public class test
{
public static void main (String args [])
{
A a = new B();
System.out.println("complete");
}
}
程序的输出是?
x.toUpperCase(); /* Line 2 */
String y = x.replace('Y', 'y');
y = y + "abc";
System.out.println(y);
程序的输出是?
{
public static void main(String [] args)
{
String s1 = "abc";
String s2 = "def";
String s3 = s2; /* Line 7 */
s2 = "ghi";
System.out.println(s1 + s2 + s3);
}
}
程序的输出是?
{
if( a )
{
System.out.println("A"); /* Line 5 */
}
else if(a && b) /* Line 7 */
{
System.out.println( "A && B");
}
else /* Line 11 */
{
if ( !b )
{
System.out.println( "notB") ;
}
else
{
System.out.println( "ELSE" ) ;
}
}
}
{
public static void main(String [] args)
{
int x = 11 & 9;
int y = x ^ 3;
System.out.println( y | 12 );
}
}
程序的输出是?
{
public static void main(String [] args)
{
String names [] = new String[5];
for (int x=0; x < args.length; x++)
names[x] = args[x];
System.out.println(names[2]);
}
}
运行如下命令:java X a b
程序的输出是?
public class Test107 implements Runnable
{
private int x;
private int y;
public static void main(String args[])
{
Test107 that = new Test107();
(new Thread(that)).start();
(new Thread(that)).start();
}
public synchronized void run()
{
for(int i = 0; i < 10; i++)
{
x++;
y++;
System.out.println("x = " + x + ", y = " + y); /* Line 17 */
}
}
}
{
public void foo()
{
assert false; /* Line 5 */
assert false; /* Line 6 */
}
public void bar()
{
while(true)
{
assert false; /* Line 12 */
}
assert false; /* Line 14 */
}
}
哪一个会导致编译失败
25题 | 被引用3次