一.常规题

(1)结构化程序设计的3种基本流程控制结构是:(顺序).(选择).(循环)
(2)判断题:一个方法最多能有return一个语句(错误).
(3)判断题:Java语言中一个Char类型的数据占用2个字节大小的内存空间(正确).
(4)以下由do-while语句构成的循环执行的次数是(B)
int k=0;
do {++k;}while(k<1);
A.     一次也不执行 B.执行一次 C.无限次 D.有语法错,不能执行
(5)下列语句序列执行后,k的值是(B)
int m=3,n=6,k=0;
while ((m++)<(--n)) ++k;
A.0    B.1    C.2    D.3
二.问答题
(1)switch是否能作用在byte上,是否能作用在long上,是否能作用在String上?
(2)简述逻辑操作(&.|.^)与条件操作(&&.||)的区别.
三.上机练习
(1)用3种循环语句求n!.
(2)Java 实现输出如下形式的数字方阵:n=4.
0  0  0   0  0
0  1  1  1  1
0  1  2  2   2
0  1  2  3  3
0  1  2  3  4
public class Example2
{
   public static void main(String[] args)
 {
     for (int i=0;i<=4 ;i++ )
     {
               for (int j=0;j<=4;j++ )
               {
                      if (j<=i)
                      {
                             System.out.printf("%2d",j);
                      }
                     else
                      {
                             System.out.printf("%2d",i);
                      }
               }
               System.out.println();
     }
 }
}
(3)输出如下形式的数字塔:n=4.
 
         1
      1 2 1
   1 2 3 2 1
1 2 3 4 3 2 1
public class Example1
{
 public static void main(String[] args)
 {
    int row=5;
    for (int i=1;i<row;i++)
    {
       for (int j=1;j<row-i;j++)
        {
          System.out.printf(" ");
      }
      for (int j=1;j<i;j++)
        {
          System.out.printf("%2d",j);
      }
      for (int j=i;j>0;j--)
        {
         System.out.printf("%2d",j);
      }
      System.out.println();
    }
 }
}
(4)编写Java应用程序,求40的阶乘(要求输出结果的每一位).
public class Example4
{
   public static void main(String[] args)
{
      double result=1.0;
      for (int i=1;i<=40;i++)
      {
         result*=i;
         System.out.println(result);
       }
 }