网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
import java.awt.*; public class X extends Frame { public static void main (String args) { X x = new X(); x.pack(); x.setVisible(true); } public X() { setLayout (new BordrLayout()); Panel p = new Panel (); add(p, BorderLayout.NORTH); Button b = new Button (“North”); p.add(b): Button b = new Button (“South”); add(b1, BorderLayout.SOUTH): } } Which two statements are true?()
- A、 The buttons labeled “North” and “South” will have the same width.
- B、 The buttons labeled “North” and “South” will have the same height.
- C、 The height of the button labeled “North” can very if the Frame is resized.
- D、 The height of the button labeled “South” can very if the Frame is resized.
- E、 The width of the button labeled “North” is constant even if the Frame is resized.
- F、 The width of the button labeled “South” is constant even if the Frame is resized.
参考答案
更多 “ import java.awt.*; public class X extends Frame { public static void main (String args) { X x = new X(); x.pack(); x.setVisible(true); } public X() { setLayout (new BordrLayout()); Panel p = new Panel (); add(p, BorderLayout.NORTH); Button b = new Button (“North”); p.add(b): Button b = new Button (“South”); add(b1, BorderLayout.SOUTH): } } Which two statements are true?()A、 The buttons labeled “North” and “South” will have the same width.B、 The buttons labeled “North” and “South” will have the same height.C、 The height of the button labeled “North” can very if the Frame is resized.D、 The height of the button labeled “South” can very if the Frame is resized.E、 The width of the button labeled “North” is constant even if the Frame is resized.F、 The width of the button labeled “South” is constant even if the Frame is resized.” 相关考题
考题
关于下面的程序段,说法正确的是( )。 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);}}
考题
在编写Java Applet程序时,若需要对发生的事件做出响应和处理,一般需要在程序的开头写上( )语句。A.import java.awt.*;B.import java.applet.*;C.import java.io.*;D.import java.awt.evcnt.*;
考题
将下面Applet程序补充完整。import java.awt.*:import java.apptet.*;public class Hi ______ {public void paint(Graghics g) {g.drawstring("Hi!",2.5,2.5);}}
考题
在下面Java Applet程序的下画线处填入代码,使程序完整并能够正确运行。import java.applet.*;import java.awt.*;public class HelloWorld ______ {public void paint(Graphics g) {g.drawString("Hello World!",25,25);}}
考题
在Java Applet程序中,如果对发生的事件做出响应和处理的时候,应该使用下列哪个语句A.import java.awt.event.*;B.import java.io.*;C.import java.awt.*;D.import java.applet.*;
考题
下列代码的下划线处应填入的方法名是______。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);}}
考题
下面程序的输出结果是( )。 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职Applet程序中,对发生的事件做出响应和处理的时候,应该使用( )。A.import java.awt.event.*;B.import java.io.*;C.import java.awt.*;D.import java.applet.*;
考题
在编写JavaApplet程序时,若需要对发生的事件作出响应和处理,一般需要在程序的开头写上( )语句。A.import java.awt.*;B.import java.applet.*C.import java.io.*;D.import java.awt.event.*;
考题
下面程序代码运行结果为( )。 import java.awt.*; public class Test { public static void main (String args[]) { String s1="a+b+c"; String s2="+"; int i=s1.lastIndexOf (s2); System.out.println(i); } }A.0B.1C.2D.3
考题
下列代码的输出结果是( )。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;
考题
在编写JavaApplication程序时,若需要使用标准输入输出语句,则必须在程序的开关写上( )语句。A.import java.awt.*;B.import java.applet. Applet;C.importjava, io.*;D.import java.awt. Graphics;
考题
下列程序在运行时会产生______。 import java.awt.*; public class ex33 { public static void maiN(String[] args) { Image im[] = new Image[4]; System.out.println (im[0] .toString ()); } }A.NumberFormatExeeptionB.ArittnneticExceptionC.ArrayIndexOutOfBoundsExcepfionD.NullPointerException
考题
在编写JavaApplication程序时,若需要使用到标准输入输出语句,则必须在程序的开头 写上( )语句。A.import java.awt.*;B.importjava.applet.Applet;C.impoortjava.io.*;D.importjava.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
考题
选择正确的语句填在下列程序的横线处。 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());
考题
下列Applet在窗口中放置2个Button,标签分别为“东”和“西”,在窗口中的位置与它们的名字相同。选择正确的语句填入横线处。 import java.awt.*; import java.applet.*; public class ex16 extends Applet { Button e, w; public void init() { e = new Button("东"); w = new Button("西"); add("East", e); add("West", w); } }A.setLayout(new BoxLayout());B.setLayout(new FlowLayout());C.setLayout(new BorderLayout());D.setLayout(new GridLayout());
考题
下列Applet实现了使用灰度值递减的顺序显示0~9,选择正确的语句填入横线处。 import java.applet.*; import java.awt.*; import java.awt.Color; public class ex24 extends Applet { public void paint(Graphics g) { int r = 0, g1 = 0, b = 0, j = 10; for(int i - 0; i < 10; i ++) { g.setColor(new Color(r, g1, b)); r += 25; g1 +=25; b +=25; j += 10; } } }A.g.drawString(i, j, 30);B.g.drawString("" + i, j, 30);C.drawString(i,j, 30);D.drawstring("" + i,j, 30);
考题
下列Applet在坐标(30,50)处以黄色字体显示“你好!”。请选择正确的语句填入横线处。 import java.awt.*; import java.applet.*; public class ex27 extends Applet { public void paint<Graphics g) { g.drawString("你好", 30, 50); } }A.setColor(Color.yellow);B.g.setColor(Color. Yellow),C.g.setFontColor(Color. yellow);D.g.setColor(Color. yellow);
考题
下列哪个选项的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);}}
考题
下列Applet用于显示提供它的主机的IP地址。请选择正确的语句填入横线处。 import java.awt.*; import java. awt. event.*; import java.applet.Applet; import java.net. *; public class ex23 extends Applet { public void init() { setLayout(new GridLayout(2, 1); Button btm = new Button("显示IP"); final Label 1 = new Label(" "); btn. addActionListener (new ActionListener ( ) { public void actionPerformed(ActionEvent ae) { try { URL ur1 = getCodeBase(); String strName = ur1.getHost(); ______ 1.setText (ia.toString()); } catch (Exception e) { e.printStackTrace (); } } }); add (btn); } }A.InetAddress ia = URL.getByName(strName);B.InetAddress ia = InetAddress.getByName(strName);C.InetAddress ia = new InetAddress.getByName(strName);D.InetAddress ia = InetAddress.getByName(ur1);
考题
选择正确的语句填入下列程序的横线处。 import java.awt.*; import java.awt.event.*; public class ex21 { static Frame. f; static FileDialog fd; public static void main(String[] args) { f = new Frame("ex21"); ______ fd. setVisible (true); System.out.println (fd.getFile ()); } }A.new FileDialog(f, "FileDialog");B.new FileDialog("FileDialog");C.fd = new FileDialog(f, "FileDialog");D.fd = new FileDialog("FileDialog");
考题
给出下列java源代码: //Point x Public class Interesting{} 在源代码//point x处添加()能符合java语法 A、import java.awt.*B、package local.utilC、class MoreInteresting{}D、protected class MoreInteresting{}
考题
在编写Java Applet程序时,若需要对发生的事件作出响应和处理,一般需要在程序的开头写上( )语句。 ;A、import java.awt.* ;B、import java.applet.* ;C、import java.io.* ;D、import java.awt.event.*
热门标签
最新试卷