网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
import java.awt.*;   public class Test extends Frame {   public Test() {   add(new Label(“Hello”) );   add(new TextField(“Hello”) );   add(new Button(“Hello”) );   pack();   show();    }   public static void main(String args) {   new Test ();   }   }   What is the result? ()
A

 The code will not compile.

B

 A Window will appear containing only a Button.

C

 An IllegalArgumentException is thrown at line 6.

D

 A Window button will appear but will not contain the Label, TextField, or Button.

E

 A Window will appear containing a Label at the top, a TextField below the Label, and a Button  below the TextField.

F

 A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.


参考答案

参考解析
解析: 暂无解析
更多 “单选题import java.awt.*;   public class Test extends Frame {   public Test() {   add(new Label(“Hello”) );   add(new TextField(“Hello”) );   add(new Button(“Hello”) );   pack();   show();    }   public static void main(String args) {   new Test ();   }   }   What is the result? ()A  The code will not compile.B  A Window will appear containing only a Button.C  An IllegalArgumentException is thrown at line 6.D  A Window button will appear but will not contain the Label, TextField, or Button.E  A Window will appear containing a Label at the top, a TextField below the Label, and a Button  below the TextField.F  A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.” 相关考题
考题 关于下面的程序段,说法正确的是( )。 import java.awt.*; import java.applet.*; public class Test extends Applet { Canvas MyCanvas; public void init() { MyCanvas=new Canvas() MyCanvas.seBackSround(Color.cyan); add(MyCanvas); } }A.程序可以运行,且看到显示B.程序编译出错C.程序可以运行,但看不到显示D.以上说法不对

考题 下面的Applet获取了相对于getDocumentBase()方法返回的目录路径为graph/java.gif的图像文件,并将它显示出来。在下面程序的划线处填入相应的语句。import java.awt.*;import java.applet.Applet;public class Test extends Applet {Image img;public void init() {【 】}public void paint (Graphics g) {g.drawlmage (img,30,25,this);}}

考题 下列程序的作用是在屏幕上显示一个200×200大小的窗口,在横线上填入相应的语句。import java.awt.*;public class Test extends Frame. {public static void main (String args[]) {Test t=new Test ("Hello");t.setSize (200,200);t.setBackground (Color.re@D)@;【 】;}public Test (String str) {super(str);}}

考题 将下面Applet程序补充完整。import java.awt.*:import java.apptet.*;public class Hi ______ {public void paint(Graghics g) {g.drawstring("Hi!",2.5,2.5);}}

考题 关于下面的程序段,说法正确的是 import java.awt.*; import java.applet.*; public class Test extends Applet{ Canvas MyCanvas; public void init(){ MyCanvas=new Canvas(); MyCanvas.setBackground(Color.cyan); add(MyCanvas); } }A.程序可以运行,且看到显示B.程序编译出错C.程序可以运行,但看不到显示D.以上说法都不对

考题 下列代码的下划线处应填入的方法名是______。import java.awt.*;import java.applet.*;public class Hello extends Applet{public void______(Graphics g){g.drawString("How are you!", 10, 10);}}A) repaintB) printlnC) paintD) showA.B.C.D.

考题 下列程序构造了一个 Swing Applet ,请在下划线处填入正确的代码Import javax.swing.*;Import java.awt.*;Public class SwingApplet extends 【 13 】 {Jlabel l = new Jlabel ( “ This is a Swing Applet. ” );Public void init(){Container contentPane = getContentPane();contentPane.add(1);}}

考题 在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class

考题 下列哪个选项的java源文件代码片段是不正确的?A.package testpackage; public class Test{ }B.import java. io. *; package testpaekage; public class Test { }C.import java.io.*; class Person { } public class Test { }D.import java.io.*; import java. awt.*; public class Test{ }

考题 下面程序的输出结果是( )。 import java.awt.*; import java.applet.*; public class HelloApplet extends Applet { public void paint(Graphics g) { g.drawstring("Hello World!", 20, 20); } }A.20,20B.Hello World!C.编译不能通过D.以上都不对

考题 下列( )选项的java源文件代码片段是不正确的。A.package testpackage; publicClass Test{}B.import java.io.*; package testpackage: publicClass Test{}C.import java.io.*; Class Person{} publicClass Test{}D.import java.io.*; import java.awt.*; publicClass Test{}

考题 在下列源代码文件Test.java中,正确定义类的代码是( )。A.pblic class test { public int x=0; public test(int x) { this. x=x;} }B.public class Test { public int x=0; public Test(int x) { this. x=x;} }C.public class Test extends T1,T2{ public int x = 0; public Test(int x){ this. x = x; } }D.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }

考题 下列代码的输出结果是( )。class parent{void printme(){System.out.println("parent");}}class child extends parent{void printme(){System. out.println("child");}void printall(){super, printme();this.printme();printme();}}public class test{public static void main(String args[]){child myc=new child();myc.printall();}}A.import java.awt.*;B.import java.applet.applet;C.import java.io.*;D.import java, awt.graphics;

考题 要下列Java Applet程序完整并能够正确运行,横线处应填人的内容是( )。 import java.applet.*; nmport java.awt.*0 public class HelloWorld{ public void paint(Graphics g){ drawstring("Hello World!",25,25); } }A.extends ThreadB.extends AppletC.extends CharD.extends Float

考题 使下列程序正常运行并且输出“Hello!”,横线处应填写的内容是( )。 class Test { public static void main(string[]args){ Test t=new Test; start; } Public void run{ System.out.println("Hello!¨); )A.extends ThreadB.extends FloatC.extends IostreamD.extends Stdio

考题 下列横线处应填写的语句是( )。 import JaVa.awt.*; public class FirstFrame. extends Frame{ public static void main(String args[]){ FirstFrame. fr=new FirstFrame("First container!"); fr.setsize(240,240); fr.setBackground(Color.yellow); } public FirstFrame(String str){ super(str); } }A.fr.setVisible(true)B.fr.setVisible(false)C.fr.setFrame(true)D.fr.setmyFrame(true)

考题 选择正确的语句填在下列程序的横线处。 import java.awt.*; import java.awt.event.*; public class ex30 { Frame. f; public static void main(String[] args) { ex30 e = new ex30(); e. te st ( ); } public void test() { f = new Frame("ex30"); ______ f.paok(); f.setVisible(true); } class MyWindowListener extends WindowAdapter { public void windowClosing(WindowEvent e) { System.exit(1); } } }A.f.addWindowListener(new MyWindowtistener());B.f.addWindowListener(MyWindowListener());C.f.addWindowAdapter(new MyWindowListener());D.addWindowListener(new MyWindowListener());

考题 在下列程序横线处填入设置窗口大小的语句,窗口长200,宽100,请选择正确的一项______。 import java.awt.*; public class ex34 extends Frame { public static void main(String[] args) { ex34 e = new ex34(); ______ e. setVisible (true); } }A.setSize(200, 100);B.e.setSize(200, 100);C.setSize(100, 200);D.e.setSize(100, 200);

考题 下列哪个选项的java源文件程序段是不正确的? ( )A.package testpackage; public class Test{ }B.import java.io.*; package testpackage; public class Test{ }C.import java.i.*; class Person{} public class Test{ }D.import java.io.*; import java.awt.*; public class Test { }

考题 下面程序构造了一个Swing Applet,在下画线处填入正确的代码。import javax.swing.*;import java.awt.*;public class SwingApplet extends ______ {JLabel 1=new JLabel("This is a Swing Applet.");public void init() {Container contentPane=getContentPane();contentPane.add(1);}}

考题 下列代码的下画线处应填入的方法名是( )。 import java.awt.*; import java.applet.*; public class Hello extends Applet{ public void (Graphics g){ 9.drawstring("How are you!",l0,10); } }A.repaintB.printlnC.paintD.show

考题 请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。[题目要求]生成下面左边图形界面,单击图中的New按钮,弹出如右图所示的对话框。源程序:import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Java_3 {public static void main(String[] args) {MulticastFrame. frame=new MulticastFrame();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.show();}}class MulticastFrame. extends JFrame. {public MulticastFrame() {setTitle("MulticastTest");setSize(WIDTH,HEIGHT);MulticastPanel panel=new MulticastPanel();Container contentPane=getContentPane();contentPane.add( (1) );}public static final int WIDTH=300;public static final int HEIGHT=200;}class MulticastPanel extends JPanel }public MulticastPanel() {JButton newButton=new JButton("New");add(newButton);ActionListener newListener=new ActionListener() {public void actionPerformed(ActionEvent event) {makeNewFrame();}};newButton.addActionListener(newListener);closeAllButton=new JButton("Close all");add(closeAllButton);}private void makeNewFrame() {final BlankFrame. frame=new BlankFrame();frame.show();ActionListener closeAllListener=new ActionListener() {public void actionPerformed(ActionEvent event) {frame. (2) (); //使窗口隐藏或消除}};closeAllButton.addActionListener( (3) );}private JButton closeAllButton;}Class BlankFrame. extends JFrame. {public BlankFrame() {(4) ++;setTitle("Frame"+counter);setSize(WIDTH,HEIGHT);setLocation(SPACING*counter,SPACING*counter);}public static final int WIDTH=200;public static final int HEIGHT=150;public static final int SPACING=30;private static int counter=0;}

考题 在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}

考题 本题的功能是获取鼠标在窗口中的位置。当鼠标移进窗口中,就会实时显示鼠标在窗口中的相对位置,比如显示为"鼠标的当前位置:X:Y"(其中,X为横坐标,Y为纵坐标)。import java.awt.*;import java.awt.event.*;import java.util.*;import javax.swing.*;public class java2{public static void main(String[]args){MouseFrame. frame=new MouseFrame();frame.setDefaultCloseoperation(JFrame.EXIT_0N CLOSE);frame.show();}}class MouseFrame. extends JFrame{public MouseFrame(){setTitle("java2");setSize(WIDTH,HEIGHT);MousePanel panel=new MousePanel();Container contentPane=getContentPane();contentPane.add(panel);}public static final int WIDTH = 300;public static final int HEIGHT=200;}class MousePanel extends JPanel{public MousePanel(){addMouseListener(new MouseHandler());addMouseMotionListener(new MouseMotionHan-dler());}public void paintComponent(Graphics g)(super.paintComponent(g);String text="鼠标指针位置:"+mousex+":"+mousey;g.drawString(text,10,10);}private int mousex,mousey;private class MouseMotionHandler {public void mouseMoved(MouseEvent event){mousex=event.getX();mousey=event.getY();repaint();}public void mouseDragged(MouseEvent event){mousex=event.getX();mousey=event.getY();repaint();}}private class MouseHandler{public void mousePressed(MouseEvent eveat){mousex=event.getX();mousey=event.getY();}}}

考题 本题中,生成一个窗口,该窗口的长、宽为屏幕长、宽的一半,并且窗口的大小不能改变。import java.awt.*;import javax.swing.*;public class java2{public.static void main(String[]args){FrameSize frame=new FrameSize();frame.setDefaultCloseoperation(JFrame.EXITON_CLOSE);frame.show();}}class FrameSize extends JFrame{public FrameSize(){setTitle("java2");Toolkit tk=Toolkit.getDefaultToolkit();Dimension screenSize=int screenHeight=screenSize.height;int screenWidth=screenSize.width;setSize(screenWidth/2,sereenHeight/2);;}

考题 在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )A.public class test { public int x=0; public test(int x) { this.x=x; } }B.public class Test { public int x=0; public Test(int x) { this.x=x; } }C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }

考题 import java.awt.*;   public class Test extends Frame {   public Test() {   add(new Label(“Hello”) );   add(new TextField(“Hello”) );   add(new Button(“Hello”) );   pack();   show();    }   public static void main(String args) {   new Test ();   }   }   What is the result? () A、 The code will not compile.B、 A Window will appear containing only a Button.C、 An IllegalArgumentException is thrown at line 6.D、 A Window button will appear but will not contain the Label, TextField, or Button.E、 A Window will appear containing a Label at the top, a TextField below the Label, and a Button  below the TextField.F、 A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.

考题 单选题import java.awt.*;   public class Test extends Frame {   public Test() {   add(new Label(“Hello”) );   add(new TextField(“Hello”) );   add(new Button(“Hello”) );   pack();   show();    }   public static void main(String args) {   new Test ();   }   }   What is the result? ()A  The code will not compile.B  A Window will appear containing only a Button.C  An IllegalArgumentException is thrown at line 6.D  A Window button will appear but will not contain the Label, TextField, or Button.E  A Window will appear containing a Label at the top, a TextField below the Label, and a Button  below the TextField.F  A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.