
我马上JAVA考试这3个题目据考得几率大,各位帮我速度编程下面的题目,一定高分悬赏啊,急用!!!
1.创建一个类,声明一个无参数的构造函数,打印类已创建的信息;再重载一个具有String参数的构造函数,打印参数信息;并创建主类验证之。2.编程包含一个单选按钮组和一个普...
1.创建一个类,声明一个无参数的构造函数,打印类已创建的信息;再重载一个具有String参数的构造函数,打印参数信息;并创建主类验证之。2.编程包含一个单选按钮组和一个普通按钮,单选按钮组中包含三个单选,文本说明分别为"普通"、"黑体"和"斜体"。选择文本标签为"普通"的单选按钮时,普通按钮中的文字为普通字体,选择文本标签为"黑体"的单选按钮时,普通按钮中的文字的字体为黑体,选择文本标签为"斜体"的单选按钮时,普通按钮中的文字的字体为斜体。3.编程包含一个列表和两个标签,在第一个标签中显示列表中被双击的选项的内容,在第二个标签中显示列表中被选中的所有选项的内容。
展开
4个回答
展开全部
第3题没看明白 最好给我发个大概示意图,谢谢
邮箱citytalent@126.com或者百度短信也可以
第一题
public class Test1 {
public Test1() {
System.out.println("这个是无参数构造器,类已创建");
}
public Test1(String s) {
System.out.println("这个是代一个String参数的构造器,传入的参数是:" + s + ",类已经创建");
}
public static void main(String[] args) {
Test1 t1 = new Test1();
System.out.println("=========分割=========");
Test1 t2 = new Test1("1234567");
}
}
第二题:
import java.awt.Button;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.security.acl.Group;
import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
public class Test2 extends Frame implements ActionListener{
ButtonGroup group = new ButtonGroup();
JRadioButton jrb1 =new JRadioButton("普通");
JRadioButton jrb2 =new JRadioButton("黑体");
JRadioButton jrb3 =new JRadioButton("斜体");
Button bt = new Button("按钮");
public Test2() {
jrb1.addActionListener(this);
jrb2.addActionListener(this);
jrb3.addActionListener(this);
setLayout(new GridLayout());
group.add(jrb1);
group.add(jrb2);
group.add(jrb3);
add(jrb1);
add(jrb2);
add(jrb3);
add(bt);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jrb1){
bt.setFont(new Font("宋体",Font.PLAIN, 12));
//System.out.println("普通");
}
if (e.getSource() == jrb2){
bt.setFont(new Font("黑体",Font.PLAIN, 12));
//System.out.println("黑体");
}
if (e.getSource() == jrb3){
bt.setFont(new Font("宋体",Font.ITALIC, 12));
//System.out.println("斜体");
}
}
public static void main(String[] args) {
Test2 t2 = new Test2();
}
}
邮箱citytalent@126.com或者百度短信也可以
第一题
public class Test1 {
public Test1() {
System.out.println("这个是无参数构造器,类已创建");
}
public Test1(String s) {
System.out.println("这个是代一个String参数的构造器,传入的参数是:" + s + ",类已经创建");
}
public static void main(String[] args) {
Test1 t1 = new Test1();
System.out.println("=========分割=========");
Test1 t2 = new Test1("1234567");
}
}
第二题:
import java.awt.Button;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.security.acl.Group;
import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
public class Test2 extends Frame implements ActionListener{
ButtonGroup group = new ButtonGroup();
JRadioButton jrb1 =new JRadioButton("普通");
JRadioButton jrb2 =new JRadioButton("黑体");
JRadioButton jrb3 =new JRadioButton("斜体");
Button bt = new Button("按钮");
public Test2() {
jrb1.addActionListener(this);
jrb2.addActionListener(this);
jrb3.addActionListener(this);
setLayout(new GridLayout());
group.add(jrb1);
group.add(jrb2);
group.add(jrb3);
add(jrb1);
add(jrb2);
add(jrb3);
add(bt);
pack();
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jrb1){
bt.setFont(new Font("宋体",Font.PLAIN, 12));
//System.out.println("普通");
}
if (e.getSource() == jrb2){
bt.setFont(new Font("黑体",Font.PLAIN, 12));
//System.out.println("黑体");
}
if (e.getSource() == jrb3){
bt.setFont(new Font("宋体",Font.ITALIC, 12));
//System.out.println("斜体");
}
}
public static void main(String[] args) {
Test2 t2 = new Test2();
}
}
展开全部
第三个题的意思不知道理解错没有:你可以看一下:
import java.awt.Button;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ComboBoxJLabelTest
{
private JFrame jf;
private JLabel jl1,jl2;
private JComboBox jcb;
private Panel pl;
ComboBoxJLabelTest()
{
jf=new JFrame("试题3");
jl1=new JLabel("目前没有内容1");
jl2=new JLabel("目前没有内容2");
pl=new Panel();
jcb=new JComboBox();
jcb.addItem("选择一");
jcb.addItem("选择二");
jcb.addItem("选择三");
jcb.addItem("选择四");
jcb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
hitComboBox();
}
});
jf.getContentPane();
jf.setLayout(new GridLayout(3,1));
pl.add(jcb);
jf.add(pl,FlowLayout.LEFT);
jf.add(jl1);
jf.add(jl2);
jf.setSize(600,200);
jf.setLocation(200,200);
jf.setVisible(true);
jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
}
void hitComboBox()
{
int index=jcb.getSelectedIndex();
switch(index)
{
case 0:
toJl1("选择一");
toJl2("选择一");
break;
case 1:
toJl1("选择二");
toJl2("选择二");
break;
case 2:
toJl1("选择三");
toJl2("选择三");
break;
case 3:
toJl1("选择四");
toJl2("选择四");
break;
default:
toJl1("非法参数");
toJl2("非法参数");
}
//System.out.println(index);
}
void toJl1(String str)
{
jl1.setText("你当前选择了: "+str);
}
void toJl2(String str)
{
jl2.setText(jl2.getText()+","+str);
}
public static void main(String[] args)
{
new ComboBoxJLabelTest();
}
}
import java.awt.Button;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ComboBoxJLabelTest
{
private JFrame jf;
private JLabel jl1,jl2;
private JComboBox jcb;
private Panel pl;
ComboBoxJLabelTest()
{
jf=new JFrame("试题3");
jl1=new JLabel("目前没有内容1");
jl2=new JLabel("目前没有内容2");
pl=new Panel();
jcb=new JComboBox();
jcb.addItem("选择一");
jcb.addItem("选择二");
jcb.addItem("选择三");
jcb.addItem("选择四");
jcb.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
hitComboBox();
}
});
jf.getContentPane();
jf.setLayout(new GridLayout(3,1));
pl.add(jcb);
jf.add(pl,FlowLayout.LEFT);
jf.add(jl1);
jf.add(jl2);
jf.setSize(600,200);
jf.setLocation(200,200);
jf.setVisible(true);
jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
}
void hitComboBox()
{
int index=jcb.getSelectedIndex();
switch(index)
{
case 0:
toJl1("选择一");
toJl2("选择一");
break;
case 1:
toJl1("选择二");
toJl2("选择二");
break;
case 2:
toJl1("选择三");
toJl2("选择三");
break;
case 3:
toJl1("选择四");
toJl2("选择四");
break;
default:
toJl1("非法参数");
toJl2("非法参数");
}
//System.out.println(index);
}
void toJl1(String str)
{
jl1.setText("你当前选择了: "+str);
}
void toJl2(String str)
{
jl2.setText(jl2.getText()+","+str);
}
public static void main(String[] args)
{
new ComboBoxJLabelTest();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这3个题你都不会。出来怎么就业?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询