考题
( 18 )下列枚举类型的定义中,包含枚举值 3 的是A ) enum test {RED, YELLOW, BLUE, BLACK};B ) enum test {RED, YELLOW=4, BLUE, BLACK};C ) enum test {RED=-1, YELLOW,BLUE, BLACK};D ) enum test {RED, YELLOW=6, BLUE, BLACK};
考题
下列枚举类型的定义中,包含枚举值3的是( )。A.enumtest{RED,YELLOW,BLUE,BLACK};B.enumtest{RED,YELLOW=4,BLUE,BLACK);C.enumtest{RED=-1,YELLOW,BLUE,BLACK};D.enumtest{RED,YELLOW=6,BLUE,BLACK);
考题
下列枚举类型的定义中,包含枚举值3的是A.enum test{RED,YELLOW,BLUE,BLACK};B.enum test{RED,YELLOW=4,BLUE,BLACK};C.enum test{RED=-1,YELLOW,BLUE,BLACK};D.erium test{RED,YELLOW=6,BLUE,BLACK};
考题
在下列枚举类型的定义中,包含枚举值3的是A.entire test(RED,YELLOW,BLUE,BLACK);B.enum test(RED,YELLOW=4,BLUE,BLACK);C.enum test(RED=-1,YELLOW,BLUE,BLACK);D.enum test(RED,YELLOW=6,BLUE,BLACK);
考题
本题的功能是用按钮来控制文本框中文本的颜色。窗口中有两个带有文字标题的而板“Sample text”和“Text col-or control”。窗口的底部还有一个复选按钮“Disable changes”。在“Sample text”面板中有一个带有字符串的文本框,而在“Text color control”面板中有三个按钮:“Black”、“Red”和“Green”,并且每个按钮上都有一个对应颜色的圆。单击任意按钮,文本框中的文本变成对应的颜色,如果选中“Dis—able changes”复选项,则三个颜色按钮变为不可用,如果取消选中复选项,则三个按钮变为可用。
考题
在下列枚举类型的定义中,包含枚举值3的是A.entire test(RED,YELLOW,BLUE,BLACK);B.entire test(RED,YELLOW,BLUE,BLACK);C.enum test(RED=-1,YELLOW,BLUE,BLACK);D.enum test(RED,YELLOW=6,BLUE,BLACK);
考题
本题的功能是监听对于菜单项和工具条的操作。窗口中有一个菜单“Color”和一个工具体,菜单“Color”中有菜单项“Yellow”、“Blue”、“Red”和“Exit”,每个菜单项都有对应的图形,单击前三个颜色菜单项,主窗口就变成对应的颜色,单击“Exit”则退出程序。工具条上有4个按钮,分别为三个颜色按钮和一个退出程序的按钮,单击任意一个颜色按钮,主窗口将变成按钮对应的颜色,单击退出程序按钮,则退出程序。import java.awt.*;import java.awt.event.*;import java.beans.*;import javax.swin9.*;public class java3{public static void main(String[]args){ToolBarFrame. frame=new ToolBarFrame();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.show();}}class ToolBarFrame. extends JFrame{public ToolBarFrame(){setTitle("java3");setSize(DEFAULT_WIDTH,DEFAUlT_HElGHT);Container contentPane=getContentPane();panel=new JPanel();contentPane.add(panel,BorderLayout.CEN-TER);Action blueAction=new ColorAction("Blue".new ImageIcon("java3-blue-ball.gif"),Color.BLUE);Action yellowAction=new ColorAction("Yellow",new Imagelcon("java3-yellow-ball.gif"),Col-or.YELLOW);Action redAction=new ColorAction("Red".new Imagelcon("java3-red-ball.gif"),Color.RED);Action exitAction=newAbstractAction("Exit".new Imagelcon("java3-exit.gif")){public void actionPerformed(ActionEvent event){System.exit(0);}};exitAction.putValue(Action.SH()RT_DESCRIP-TIoN,"Exit");JToolBar bar=new JToolBar();bar.add(blueAction);bar.add(yellowAction);bar.add(redAction);bar.addSeparator();bar.add(exitAction);contentPane.addToolBar(bar,BorderLayout.NoRTH);JMenu menu=new JMenu("Color"):menu.add(yellowAction);menu.add(blueAction);menu.add(redAction);menu.add(exitAction);JMenuBar menuBar=new JMenuBar():menuBar.add(menu);SetJ Menu(menuBar);}public static final int DEFAULT_WIDTH=300;public static final int DEFAULT_HEIGHT=200;private JPanel panel;class ColorAction extends AbstractAction{public ColorAction(String name,Icon icon,Colorc){putValue(Action.NAME,name);putValue(Action.SMALL_ICON,icon);putValue(Action.SHORT_DESCRIPTION,name+"background");putValue("Color",c);}public void actionPerformed(ActionEvent evt){Color C=(Color)getValue("Color");panel.setBackcolor(c);}}}
考题
定义一个颜色的枚举类型Color,下面正确的是()。A.public enum Color {red, green, yellow, blue}B.public enum Color {1:red, 2:green, 3:yellow, 4:blue}C.public enum Color {1:red; 2:green; 3:yellow; 4:blue}D.public enum Color {Stringred, String green, String yellow, String blue}
考题
8、定义一个颜色的枚举类型Color,下面正确的是()。A.public enum Color {red, green, yellow, blue}B.public enum Color {1:red, 2:green, 3:yellow, 4:blue}C.public enum Color {1:red; 2:green; 3:yellow; 4:blue}D.public enum Color {Stringred, String green, String yellow, String blue}