ABCD
成都创新互联是一家专注于网站制作、成都网站制作与策划设计,夹江网站建设哪家好?成都创新互联做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:夹江等地区。夹江做网站价格咨询:18982081108
package structs;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) {
int i = 1;
switch (i) {
case 1:
System.out.println("int");
}
byte b = 1;
switch (b) {
case 1:
System.out.println("byte");
}
char c = 'A';
switch (c) {
case 'A':
System.out.println("char");
}
short s = 1;
switch (s) {
case 1:
System.out.println("shot");
}
}
}
2.ABC
D那个是char的数组,跟String没有关系
package structs;
/**
* Hello world!
*
*/
public class App {
public static void main(String[] args) {
String str = "abc";
String str2 = new String();
String str3 = new String("abc");
char[] chs = { 'a', 'b', 'c' };
}
}
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Choice;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JFrame;
public class Choose extends JFrame implements ItemListener {
/**
*
*/
private static final long serialVersionUID = 1L;
Label l1, l2;
TextField t1, t2;
CheckboxGroup checkboxGroup = new CheckboxGroup();
Checkbox checkbox1 = new Checkbox("QQ", checkboxGroup, false);
Checkbox checkbox2 = new Checkbox("MSN", checkboxGroup, false);
Checkbox checkbox3 = new Checkbox("ICQ", checkboxGroup, false);
Choice c;
public Choose() {
super("简单小程序");
this.setLayout(new FlowLayout());
l1 = new Label("选择你常用的软件:");
l2 = new Label("选择你喜欢的水果:");
checkbox1.addItemListener(this);
checkbox2.addItemListener(this);
checkbox3.addItemListener(this);
t1 = new TextField(20);
t2 = new TextField(20);
c = new Choice();
c.addItemListener(this);
c.add("苹果");
c.add("橘子");
c.add("香蕉");
c.add("梨子");
this.add(l1);
this.add(checkbox1);
this.add(checkbox2);
this.add(checkbox3);
this.add(t1);
this.add(l2);
this.add(c);
this.add(t2);
this.setSize(450, 200);
this.setVisible(true);
}
public static void main(String[] args) {
new Choose();
}
public void itemStateChanged(ItemEvent e) {
if (e.getSource() == checkbox1) {
t1.setText("你常用的软件是:" + checkbox1.getLabel());
}
if (e.getSource() == checkbox2) {
t1.setText("你常用的软件是:" + checkbox2.getLabel());
}
if (e.getSource() == checkbox3) {
t1.setText("你常用的软件是:" + checkbox3.getLabel());
}
t2.setText("你喜欢的水果是:" + c.getSelectedItem());// 得到选中的下拉列表值
}
}
1、ABC
2、AD
3、CD
4、AC
5、CD
6、ACD
7、BD
8、AC
9、BC
按照题目要求编写的用javaBean规范设计的学生类Student的Java程序如下
需要创建user.java.test包,把Student.java文件和Test.java文件放入包中,编译Student.java文件并且编译运行Test.java文件得到运行结果
Student.java文件代码如下
package user.java.test;
import java.io.Serializable;
public class Student implements Serializable{
private static final long serialVersionUID = 1L;
private String no;
private String name;
private double score;
public Student(){}
public Student(String no,String name,double score){
this.no=no;
this.name=name;
this.score=score;
}
public String getNo(){ return no;}
public void setNo(String no){ this.no=no;}
public String getName(){ return name;}
public void setName(String name){ this.name=name;}
public double getScore(){ return score;}
public void setScore(double score){ this.score=score;}
public String toString(){
return "学号:"+no+",姓名:"+name+",成绩:"+score;
}
public static double getAvg(Student[] sArray){
double sum=0,avg;
for(int i=0;isArray.length;i++){
sum=sum+sArray[i].getScore();
}
avg=sum/sArray.length;
return avg;
}
}
Test.java文件代码如下
package user.java.test;
public class Test{
public static void main(String[] args){
Student[] sArray=new Student[5];
sArray[0]=new Student("001","张三",89.5);
sArray[1]=new Student("002","李四",82.5);
sArray[2]=new Student("003","王五",93);
sArray[3]=new Student("004","赵六",73.5);
sArray[4]=new Student("005","孙七",66);
System.out.println("这些学生的平均分:"+Student.getAvg(sArray));
for(int i=0;isArray.length;i++){
System.out.println(sArray[i].toString());
}
}
}
1.AC
2.CD
3.ABCD
4.ACD(因为能正常运行,即没有异常,不执行catch块内的TEST2)
但又不一定,如果你的unsafe()声明了throws SafeException,并在程序中会抛出这样的错误,则是 BCD ,我看那个方法名称起得跟异常名有点像,所以……
5.BC
6.ABCD
7.BD
8.ABCD
9.ABC(没理解题意,如果意思是下列关键字哪些能用于声明成员使用范围,就差不多全选了)
10.AB
1
A 父类引用指向子类实例
C
2
A 形参类形不一样,包括顺序,长度等;返回值不包含在内
C
3
A
C
D
4
A, B
5 B C D
6 A B
7 C D
8 A B C D
9 A D
10 ABC