多选题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

题目
多选题
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”相关问题
  • 第1题:

    本题的功能是用按钮来控制文本框中文本的颜色。窗口中有两个带有文字标题的面板“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 void

    windowClosing(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 this

    text"):

    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");

    }

    }


    正确答案:
    第1处:upper.setLayout(newBorderLayout())第2处:classButtonListenerimplementsActionListener第3处:this.c=c【解析】第一处令面板upper采用BorderLayout布局。第二处是要求类ButtonListener实HActionListener接口,达到通过按钮改变字体颜色的目的。第三处是设置按钮前圆形的颜色。

  • 第2题:

    阅读以下说明和 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); } }


    正确答案:(1) MyColor[]
    (2) this.number
    (3) this.palette
    (4) static final
    (5) new MyColor

  • 第3题:

    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”

    正确答案:D

  • 第4题:

    现有:  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、  0
    • B、  1
    • C、  2
    • D、  3

    正确答案:D

  • 第5题:

    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);

    正确答案:B,C

  • 第6题:

    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;

    正确答案:C,E

  • 第7题:

    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 null
    • C、 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.

    正确答案:F

  • 第8题:

    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、 Tested
    • B、 Compilation fails.
    • C、 The code runs with no output.
    • D、 An exception is thrown at runtime.

    正确答案:B

  • 第9题:

    单选题
    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

     Tested

    B

     Compilation fails.

    C

     The code runs with no output.

    D

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第10题:

    单选题
    现有:  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

      0

    B

      1

    C

      2

    D

      3


    正确答案: C
    解析: 暂无解析

  • 第11题:

    多选题
    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;


    正确答案: A,B
    解析: 暂无解析

  • 第12题:

    单选题
    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”


    正确答案: A
    解析: 暂无解析

  • 第13题:

    阅读下列说明和 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() { cout<<"Red: " << 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; }


    正确答案:(1) free(palette)
    (2) this->number
    (3) static const
    (4) new MyColor
    (5) new Drawing()

  • 第14题:

    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 null
    • C、 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.

    正确答案:F

  • 第15题:

    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[])

    正确答案:D,E

  • 第16题:

    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 = null
    • C、 baz = blue
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:E

  • 第17题:

    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++)

    正确答案:A

  • 第18题:

    现有:  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、  0
    • B、  1
    • C、  2
    • D、  3

    正确答案:C

  • 第19题:

    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;

    正确答案:B

  • 第20题:

    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.

    正确答案:A

  • 第21题:

    单选题
    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 null

    C

     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.


    正确答案: F
    解析: 暂无解析

  • 第22题:

    单选题
    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 = null

    C

     baz = blue

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


    正确答案: C
    解析: A java.lang.ArrayIndexOutOfBoundsException is thrown because of line 3, should be args[0].

  • 第23题:

    单选题
    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 null

    C

     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.


    正确答案: F
    解析: 暂无解析

  • 第24题:

    单选题
    现有:  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

      0

    B

      1

    C

      2

    D

      3


    正确答案: B
    解析: 暂无解析