package sun.scjp;  public enum Color { RED, GREEN, BLUE }  package sun.beta;  // insert code here  public class Beta {  Color g = GREEN;  public static void main( String[] argv)  { System.out.println( GREEN); }  }  The class Beta and the enum Color are in different packages.  Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?()A、 import sun.scjp.Color.*;B、 import static sun.scjp.Color.*;C、 import sun.scjp.Color; import static sun.scjp.Color.*;D、 import sun.scjp.*; import static sun.scjp.Color.*;E、 import sun.scjp.Color; import static sun.scjp.Color.GREEN;

package sun.scjp;  public enum Color { RED, GREEN, BLUE }  package sun.beta;  // insert code here  public class Beta {  Color g = GREEN;  public static void main( String[] argv)  { System.out.println( GREEN); }  }  The class Beta and the enum Color are in different packages.  Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?()

  • A、 import sun.scjp.Color.*;
  • B、 import static sun.scjp.Color.*;
  • C、 import sun.scjp.Color; import static sun.scjp.Color.*;
  • D、 import sun.scjp.*; import static sun.scjp.Color.*;
  • E、 import sun.scjp.Color; import static sun.scjp.Color.GREEN;

相关考题:

设有说明var color:(red,green,yellow,blue);a:boolean;下面语句正确的是( )。 Aolor:=‘green‘;Bwriteln(green);Cwriteln(color);Da:=color=red;

packagesun.scjp;publicenumColor{RED,GREEN,BLUE}packagesun.beta;//insertcodeherepublicclassBeta{Colorg=GREEN;publicstaticvoidmain(String[]argv){System.out.println(GREEN);}}TheclassBetaandtheenumColorareindifferentpackages.Whichtwocodefragments,insertedindividuallyatline2oftheBetadeclaration,willallowthiscodetocompile?()A.importsun.scjp.Color.*;B.importstaticsun.scjp.Color.*;C.importsun.scjp.Color;importstaticsun.scjp.Color.*;D.importsun.scjp.*;importstaticsun.scjp.Color.*;E.importsun.scjp.Color;importstaticsun.scjp.Color.GREEN;

对于这样的一个枚举类型:enum Color:byte{Red,Green,Blue,Orange}string[] ss=Enum.GetNames(typeof(Color));byte[] bb=Enum.GetValues(typeof(Color));试写一段程序显示出枚举类型中定义的所有符号名称以及它们对应的数值。

对于这样的一个枚举类型:enum Color:byte{Red,Green,Blue,Orange}

本题的功能是用按钮来控制文本框中文本的颜色。窗口中有两个带有文字标题的面板“Sample text”和“Text color control”,窗口的底部还有一个复选按钮“Disable changes”。在“Sample text”面板中有一个带有字符串的文本框,而在“Text color control”面板中有三个按钮:“Black”、“Red”和“Green”,并且每个按钮上都有一个对应颜色的圆。单击任意按钮,文本框中的文本变成对应的颜色,如果选中“Disable changes”复选项,则三个颜色按钮变为不可用,如果取消选中复选项,则三个按钮变为可用。import javax.swing.*;import java.awt.*;import java.awt.event.*;public class java3 extends JFrame{private JPanel upper,middle,lower;private JTextField text;private JButton black,red,green;private JCheckBox disable;public java3(String titleText){super(titleText);addWindowListener(new WindowAdapter(){public voidwindowClosing(WindowEvent e){System.exit(0);}});upper=new JPanel();upper.setBorder(BorderFactory.ereateTitledBor-der("Sample text"));upper.setlayout(new BorderLayout());text=new JTextField("Change the color of thistext"):upper.add(text,BorderLayout.CENTER);middle=new JPanel();middle.setBorder(BorderFactory.createTitledBor-der("Text color control"));middle.setLayout(new FlowLayout(FlowLayout.CENTER)):black=new JButton("Black",new ColorIcon(Color.black));black.addActionListener( new ButtonListener(Color.black));middle.add(black);red=new JButton("Red",new ColorIcon(Col-or.red));red.addActionListener(new ButtonListener(Col-or.red));middle.add(red);green=new JButton("Green",new ColorIcon(Color.green));green.addActionListener(new ButtonListener(Color.green));middle.add(green);lower=new JPanel();lower.setLayout(new FlowLayout(FlowLayout.RIGHT));disable=new JCheckBox("Disable changes"):disable.addItemListener(new ItemListener()(public void itemStateChanged(ItemEvent e){boolean enabled=(e.getStateChange()= =ItemEvent.DESELECTED):black.setEnabled(enabled);red.setEnabled(enabled);green.setEnabled(enabled);}});lower.add(disable);Container cp=getContentPane();cp.add(upper,BorderLayout.NORTH);cp.add(middle,BorderLayout.CENTER);cp.add(10wer,BorderLayout.SoUTH);pack();setVisible(true);}class ButtonListener extends ActionListener{private Color c;public ButtonListener(Color c){this.c=c;}public void actionPerformed(ActionEvent e){text.setForeground(c);}}class ColorIcon implements Icon{private Color c;private static final int DIAMETER=10;public ColorIcon(Color c){c=c;}public void paintlcon(Component cp,Graphics g,int x,int y){g.setColor(c);g.fillOval(X,y,DIAMETER,DIAMETER);g.setColor(Color.black);g.drawOval(x,y,DIAMETER,DIAMETER);}public int getlconHeight(){return DIAMETER;}public int getlconWidth(){return DIAMETER;}}public static void main(String[]args){new java3("advance");}}

阅读下列说明和 C++代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 设计 RGB 方式表示颜色的调色板,进行绘图,其类图如图 5-1 所示。该程序的 C++代码附后。图5-1 类图【C++代码】 include iostream include stdlib.h include ctime using namespace std; class MyColor{ private: int red; int green; int blue; public: MyColor() {red = 0; green = 0; blue = 0; } ~MyColor() { } MyColor(int red ,int green ,int blue) { this-red = red; this-green = green; this-blue = blue;} //其他方法略 void print() { coutRed: red \tGreen: green \tBlue blue endl; } }; class Palette ( private: int number; MyColor** palette; public: Palette() { number = 256; palette = (MyColor*)malloc (sizeof(MyColor ) *number); } ~Palette () { for (int i = 0; i number; i++) { delete palette[i]; } (1) ; } Palette(MyColor** pale ,int number) { (2) = number; palette = (MyColor**)malloc(sizeof(MyColor*)*number) ; memcpy(palette ,pale ,sizeof(pale)*number); } //其他方法略 void print () { for (int i = 0; i number; i++) { cout i : ; palette[i]-print(); } } }; class Drawing{ public: (3) int COLORNUMBER = 16; public: ~Drawing () { } void draw() ( Palette* palette; int red ,green ,blue; MyColor* color[COLORNUMBER); srand((unsigned)time(O)); for (int i = 0; i COLORNUMBER; i++) red=rand ()% 256; green = rand() % 256; blue = rand ()% 256; color [i) = (4) (red ,green ,blue); } palette = new Palette(color ,COLORNUMBER); palette-print(); for (int i = 0; i COLORNUMBER; i++) delete color[i]; } }; int main () { Drawing * d = (5) ; d-draw(); delete d; }

阅读以下说明和 Java 代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 设计 RGB 方式表示颜色的调色板,进行绘图。其类图如图 6-1 所示。该程序的 Java代码附后。图6-1 类图【Java 代码】 //颜色类 class MyColor { private int red ,green, blue; public MyColor( ) { red = o; green = 0; blue = 0; } public MyColor(int red ,int green ,int blue) { this.red = red; this.green = green; this.blue = blue; } //其他方法略 public String toString( ) { return Red: + red + \tGreen: + green + \tBlue + blue; } } //调色板类 class Palette { public int number; / /颜色数 private (1)palette; //颜色表 public Palette( ) { number = 256; palette = new MyColor[number); } public Palette(MyColor[] palette ,int number) { (2)= number; (3)= palette; } //其他方法略 public String toString( ) { String str = ; for (int i = 0; i number; i++) { str +=i+ : + palette[i] + \n; } return str; } //绘图类 class Drawing { public (4) int COLORNUMBER = 16; public static void main(String[] args) { Palette palette; int red ,green ,blue; MyColor[] color = new MyColor[COLORNUMBER]; for (int i = 0; i COLORNUMBER; i++) { red = (int) (Math.random( ) * 256); green = (int) (Math.random( ) * 256); blue = (int) (Math.random( ) * 256); color [i] = (5) (red ,green ,blue); } palette = new Palette(color ,COLORNUMBER); System.out.println(palette); } }

public class test(  public static void main(string[]args){  string foo = args [1];  string foo = args [2];  string foo = args [3];  }  )  And command line invocation: Java Test red green blue   What is the result?()  A、 Baz has the value of “”B、 Baz has the value of nullC、 Baz has the value of “red”D、 Baz has the value of “blue”E、 Bax has the value of “green”F、 The program throws an exception.

public class Test {   public static void main (String args) {  string foo = “blue”;  string bar = foo;   foo = “green”;   System.out.printIn(bar);   }   }   What is the result?()  A、 An exception is thrown.B、 The code will not compile.C、 The program prints “null”D、 The program prints “blue”E、 The program prints “green”

Which declarations will allow a class to be started as a standalone program?()  A、public void main(String args[])B、public void static main(String args[])C、public static main(String[] argv)D、final public static void main(String [] array)E、public static void main(String args[])

现有:  1. abstract class Color2  {      2.    //insert code here      3.  }      4.  5. public class Blue2 extends Color2  {  6.public  String getRGB()  {  return  "blue";  }      7.  }  和4个声明:  public abstract  String getRGB();     abstract  String getRGB();  private abstract  String getRGB();      protected abstract String getRGB();  分别插入到第2行,有多少行可以编译?()     A、  0B、  1C、  2D、  3

public class Test {  public static void main( String[] args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.println(“baz = “ + baz); }  }   And the command line invocation: java Test red green blue   What is the result?()  A、 baz =B、 baz = nullC、 baz = blueD、 Compilation fails.E、 An exception is thrown at runtime.

class Sock {  String size;  String color;  public boolean equals(Object o) {  Sock s = (Sock) o;  return color.equals(s.color);   }  // insert code here  }  哪两个满足 hashCode 的约定?()A、public int hashCode() { return 343; }B、public int hashCode() { return size.hashCode (); }C、public int hashCode() { return color.hashCode (); }D、public int hashCode() { return (int) (Math.random() * 1000);

public class Ball {  public enum Color { RED, GREEN, BLUE };  public void foo() {  // insert code here  { System.out.println(c); }  }  }  Which code inserted at line 14 causes the foo method to print RED, GREEN, and BLUE?() A、 for( Color c : Color.values())B、 for( Color c = RED; c = BLUE; c++)C、 for( Color c; c.hasNext() ; c.next())D、 for( Color c = Color[0]; c = Color[2]; c++)E、 for( Color c = Color.RED; c = Color.BLUE; c++)

现有:  1. abstract class Color  {  2.protected abstract  String getRGB();     3.  }     4.  5. public class Blue extends Color  {     6.    //insert code here      7.  }  和四个声明:  public String getRGB()  {  return "blue";  }      String getRGB()  {  return  "blue";  )  private  String getRGB()  {  return  "blue";  }      protected String getRGB()  {  return "blue";  )      分别插入到第6行,有几个可以通过编译?()    A、  0B、  1C、  2D、  3

public class test(   public static void main(stringargs){   string foo = args [1];   string foo = args ;   string foo = args ;   }   )   And command line invocation:  Java Test red green blue  What is the result? () A、 Baz has the value of “”B、 Baz has the value of nullC、 Baz has the value of “red”D、 Baz has the value of “blue”E、 Bax has the value of “green”F、 The program throws an exception.

Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.   class Base {   public void print( ) {   System.out.println("base");   }   }   class Extention extends Base {   public void print( ) {   System.out.println("extension");   // insert line of implementation here   }   }   public class Q294d {   public static void main(String args[]) {   Extention ext = new Extention( );   ext.print( );   }   }   Fill in a single line of implementation.()

10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  Which code, inserted at line 16, will cause a java.lang.ClassCastException?() A、 Alpha a = x;B、 Foo f= (Delta)x;C、 Foo f= (Alpha)x;D、 Beta b = (Beta)(Alpha)x;

interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()  A、 TestedB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

You work as a Web Developer at Certkiller.com. You make use of Microsoft ASP.NET 3.5 in orderto create a Web Site.  In a separate code file you create the following class:  public static class _Colors {  public static Color NormalActivityColor = Color.Green;  public static Color WarningActivityColor = Color.Yellow;  public static Color ErrorActivityColor = Color.Red;    public static Color GetRandomColor()  {  Random random = new Random((int)DateTime.Now.Ticks);  int randomArgbValue = random.Next();  Color color = Color.FromArgb(255, Color.FromArgb(randomArgbValue));  return color;  }  }  You need to ensure that the class is consumed by the Web Site. You have to configure the WebSite project.  What should you do?()A、You should add the file to the App_Code folder of the project.B、You should add a Register directive that will reference the file to every page that makes use ofthe class.C、This can be accomplished by referencing the file in the assemblies segment of the Web.configfile.D、This can be accomplished by referencing the file in the httpHandlers segment of the Web.configfile.

单选题interface Beta {}  class Alpha implements Beta {  String testIt() {  return “Tested”;  }  }  public class Main1 {  static Beta getIt() {  return new Alpha();  }  public static void main( String[] args ) {  Beta b = getIt();  System.out.println( b.testIt() );  }  }  What is the result?()A TestedB Compilation fails.C The code runs with no output.D An exception is thrown at runtime.

单选题public class test(  public static void main(string[]args){  string foo = args [1];  string foo = args [2];  string foo = args [3];  }  )  And command line invocation: Java Test red green blue   What is the result?()A Baz has the value of “”B Baz has the value of nullC Baz has the value of “red”D Baz has the value of “blue”E Bax has the value of “green”F The program throws an exception.

单选题现有:  1. abstract class Color2  {      2.    //insert code here      3.  }      4.  5. public class Blue2 extends Color2  {  6.public  String getRGB()  {  return  "blue";  }      7.  }  和4个声明:  public abstract  String getRGB();     abstract  String getRGB();  private abstract  String getRGB();      protected abstract String getRGB();  分别插入到第2行,有多少行可以编译?()A  0B  1C  2D  3

单选题public class Test {  public static void main( String[] args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.println(“baz = “ + baz); }  }   And the command line invocation: java Test red green blue   What is the result?()A baz =B baz = nullC baz = blueD Compilation fails.E An exception is thrown at runtime.

单选题public class test(   public static void main(stringargs){   string foo = args [1];   string foo = args ;   string foo = args ;   }   )   And command line invocation:  Java Test red green blue  What is the result? ()A Baz has the value of “”B Baz has the value of nullC Baz has the value of “red”D Baz has the value of “blue”E Bax has the value of “green”F The program throws an exception.

单选题public class Test {  public static void main (String [] args)  {  string foo = “blue”;  string bar = foo;  foo = “green”;  System.out.printIn(bar);  }  }   What is the result?()A An exception is thrown.B The code will not compile.C The program prints “null”D The program prints “blue”E The program prints “green”

单选题现有:  1. abstract class Color  {  2.protected abstract  String getRGB();     3.  }     4.  5. public class Blue extends Color  {     6.    //insert code here      7.  }  和四个声明:  public String getRGB()  {  return "blue";  }      String getRGB()  {  return  "blue";  )  private  String getRGB()  {  return  "blue";  }      protected String getRGB()  {  return "blue";  )      分别插入到第6行,有几个可以通过编译?()A  0B  1C  2D  3