阅读下面的程序,该程序( ).main( ){ int a=5,b=0,c=0;if(a=b+c) printf("***/n");
阅读下面的程序,该程序().
main()
{ int a=5,b=0,c=0;
if(a=b+c) printf("***/n");
else printf("$$$/n"); }
A、可以通过编译但不能通过连接
B、输出***
C、输出$$$
D、有语法错不能通过编译
阅读下面的程序,该程序().
main()
{ int a=5,b=0,c=0;
if(a=b+c) printf("***/n");
else printf("$$$/n"); }
A、可以通过编译但不能通过连接
B、输出***
C、输出$$$
D、有语法错不能通过编译
第1题
A.9
B.5
C.6
D.6.1
第2题
class Check{
public static void main(String args[]){
double d =12.3;
Decrementer dec =new Decrementer();
dec.decrement(d);
System.out.println(d);
}
}
class Decrementer{
public void decrement(double decMe){
decMe=decMe-1.0;
}
}
A、 打印输出0.0
B、 打印输出-1.0
C、 打印输出12.3
D、 打印输出11.3
第3题
阅读下列程序,请写出该程序的输出结果。
public class C
{
int x=10;
static int y=20;
public static void main(String[] args)
{
C obj1=newC();
C obj2=newC();
obj1.x*=2;
obj1.y*=3;
obj2.x+=4;
obj2.y+=5;
System.out.println(obj1.x);
System.out.println(obj1.y);
System.out.println(obj2.x);
System.out.println(obj2.y);
}
}
第4题
阅读下面的程序,填写程序中缺少的部分,并把程序的输出结果写出来;
classTest{
staticvoidShowArrayInfo(int[]student){
for(inti=0;i
Console.Write(student[i]++);
Console.Write(“”);
}
}
staticvoidMain(){
int[]student=newint[]{1,2,3,4,5};
ShowArrayInfo(student);
Console.Write(“/n”);
ShowArrayInfo(student);
}
}
输出结果:
第5题
阅读下列程序,请写出该程的功能。
import java.io.*;
public class Class34
{
public static void main(String[] args)
{
File inputFile=new File("file1.txt");
File utputFile=new File("file2.txt");
int ch;
try
{
FileReader in=new FileReader(inputFile);
FileWriter ut=new FileWriter(outputFile);
while((ch=in.read())!=-1)out.write(ch);
in.close();out.close();
}
catch(FileNotFoundExceptione1)}
{System.out.println("文件没有找到!"+e1);}
catch(IOException e2)
{System.out.println("FilereadError!"+e2);}
}
}
第6题
A.输出:构造
B.输出:static构造
C.输出:static
D.没有输出结果
第7题
import java.io.*;
public class Test {
public static void main(String args[]) {
try {
String s = "ABCDE" byte b[]=s.getBytes()
FileOutputStream file =
new FileOutputStream("test.txt", true)
file.write(b) file.close() }
catch(IOException e) {
System.out.println(e.toString()) }
}
}
A、ABCABC
B、ABCDE
C、Test
D、ABCDEABCDEABCDE
第8题
A.null—0周星驰—27
B.null—27周星驰—27
C.周星驰—0null—27
D.周星驰—27null—27
第9题
阅读下列程序,写出程序功能。
import j ava. awt. *;
import j avax. swing. *;
import j ava. awt. event. *;
public class C3401 implements ActionListener
{
JFrame. frmFrame;
JButton btnUp, btnDown;
public C3401()
{
frmFrame=new JFrame("按钮应用") ;
frmFrame. setLayout(new CridLayout(2, 1) ) ;
btnUp=new JButton("上") ;
btnUp. setActionCommand("btnUp") ;
btnUp. addActionListener(this) ;
btnDown=new JButton("下") ;
btnDown. setActionCommand("btnDown") ;
btnDown. addActionListener(this) ;
frmFrame. add(btnUp) ;
frmFrame. add(btnDown) ;
frmFrame. pack() ;
frmFrame. setVisible(true) ;
}
public void actionPerformed(ActionEvent e)
{
String cmd=e. getActionCommand() ;
if(cmd. equals("btnDown")
if(btnUp. getBackground() ==Color. BLUE.
btnUp. setBackground(Color. red) ;
else
btnUp. setBackground(Color. blue) ;
else
if(btnDown. getBackground() ==Color. BLUE.
btnDown. setBackground (Color. red) ;
else
btnDown. setBackground(Color. blue) ;
}
public static void main(String[] args)
{
new C3401() ;
}
}
第10题
阅读下列程序,请写出程序的运行结果。
public class C
{
public static void main(String[] args)
{
String text="public static void main(String[] args)";
int theCount=0;
int index=-1;
String theStr="i";
index=text.indexOf(theStr);
while(index>=0)
{
++theCount;
index+=theStr.length();
index=text.indexOf(theStr,index);
}
System.out.println("The Text contains"+theCount+"i");
}
}