更多"阅读下面的程序段: for i=1 to 3 for j=i "的相关试题:
[单项选择]阅读下面的程序段:
publiC class Sun
public static void main (String args[ ])
int a=0;
for(int i=1;i<=3;i++)
for(int j=1;j<=i;j++)
for(int k=j;k<=3;k++)
a=a+1;
System.out.println(
A. ;
B. 9
C. 14
D. 21
[单项选择]阅读下面的程序段: public class Sun { public static void main(String args[ ]) { int a=0 for(int i=1;i<=3;i++) { for(int j=1;j<-i;j++) { for(int k=j;k<=3;k++) { a=a+1; } } } System.out.println(A) 我; }}执行上面的3重循环后,a的值为( )。
A. 3
B. 9
C. 14
D. 21
[单项选择]阅读和理解下面程序段:
class Manager extends Employee
public Manager(String n,double s,int year,int month,int day)
super(n,s,year,month,day);
bonus=0;
public double getSalary( )
double baseSalary=super.gerSalary( );
return baseSalary+bonus;
public void setBonus(double b)bonus=b;
private double bonus;
Manager是Employee的子类,其理由是
A. Manager的适用范围较宽
B. extends关键字声明
C. Manager的域减小了
D. 雇员是一个经理
[单项选择]阅读下面程序,则程序段的功能是
#include"stdio.h"
main( )
int c[]=23,1,56,234,7,0,34,i,j,t;
for(i=1;i<7;i++)
t=c[i];j=i-1;
while(j>=0 && t>c[j])
c[j+1]=c[j];j--;
c[j+1]=t;
for(i=0;i<7;i++)
printf("%d",c[i]);
putchar(’/n’);
A. 对数组元素的升序排列
B. 对数组元素的降序排列
C. 对数组元素的倒序排列
D. 对数组元素的随机排列
[单项选择]阅读和理解下面程序段: class Manager extends Employee{ public Manager(String n,double s,int year,int month,int day){ super(n,s,year,month,day); bonus=0; } public double getSalary( ){ double baseSalary=super.gerSalary( ); return baseSalary+bonus; } public void setBonus(double b){bonus=b; } private double bonus; } Manager是Employee的子类,其理由是
A. Manager的适用范围较宽
B. extends关键字声明
C. Manager的域减小了
D. 雇员是一个经理
[单项选择]
阅读和理解下面程序段:
class Manager extends Employee{
public Manager(String n,double s,int year,int month,int day) {
super(n,s,year,month,day);
bonus=O;
}
public double getSalary( ){
double baseSalary=super,gerSalary( );
return baseSalary+bonus;
}
public void setBonus(double b);
{
bonus=b;
}
private double bonus;
}
Manager是Employee的子类,其理由是()
A. Manager的适用范围较宽
B. extends关键字声明
C. Manager的域减小了
D. 雇员是一个经理
[填空题]bar为一JScrollBar组件,阅读下面程序段,请在程序中的画线处填入正确的语句使程序能够正确运行。
...
public WellAdjusted( )
super("Well Adjusted");
setSize(350,100);
bar.addAdjustmentListener(this);
value.setHorizontalAlignment(SwingConstants.CENTER);
value.setEditable(false);
JPanel pane = new JPane( );
pane.setLayout(new BorderLayout( ));
pane.add(value,"Center"):
pane.add(bar,"South");
setContentPane(pane);
public void adjustmentValueChanged(AdjustmentEvent evt)
【12】
if(source ==bar)
int newValue bar.getValue( );
value.setText(""+newValue);
repaint( );
[填空题]阅读下面程序段,SelectItem应用程序显示从文本域的组合框中进行选择,请在程序中的画线处添上正确的语句使得程序能够正确运行。
...
JTextField result = new JTextField( );
JComboBox pick = new JComboBox ( );
public SelectItem( )
{
super ("Select Item");
pick.addItemListener(this);
pick.addItem("Navigtor");
pick.addItem("Internet Explorer");
pick.addItem("Opera");
pick.setEditable(false);
result.setHorizontalAlignment(SwingConstants.CENTER);
result, setEditable (false);
pane.setLayout(new BorderLayout( ));
【12】
pane.add(pick,"Center");
pane.add(result,"South");
setContentPane(pane);
}
public void itemStateChanged(ItemEvent evt)
{
Object source = evt.getSource( );
if(source == pick)
{
Object newPick = evt.getItem( );
result .setText(newPick.toString( )+" is the selection. ");
}
repaint( );
}
[填空题]bar为一JSerollBar组件,阅读下面程序段,请在程序中的画线处填入正确的语句使程序能够正确运行。
…
public WellAdjusted( )
{
super("Well Adjusted");
setSize(350,100);
bar.addAdjustmentListener(this);
value.setHorizontalAlignment(SwingConstants.CENTER);
value.setEditable(false);
JPanel pane=new JPane( );
pane.setLayout(new BorderLayout( ));
pane.add(value,"Center"):
pane.add(bar,"South");
setContentPane(pane);
}
public void adjustmentValueChanged(AdjustmentEvent evt)
{
【12】
if(source==bar)
{
int newValue bar.getValue( );
value.setText(""+newValue);
}
repaint( );
}
…