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

题目内容 (请给出正确答案)
public class X extends Frame{public static void main(String[] args){X x=new X();x.pack();x.setVisible(true);}public X(){setLayout(new GridLayout(2,2));Panel p1=new Panel(); add(p1);Button b1

A.all change height and width

B.Button One change height

C.Button Two change height and Button Three change width

D.Button Four change height and width


参考答案

更多 “ public class X extends Frame{public static void main(String[] args){X x=new X();x.pack();x.setVisible(true);}public X(){setLayout(new GridLayout(2,2));Panel p1=new Panel(); add(p1);Button b1 A.all change height and widthB.Button One change heightC.Button Two change height and Button Three change widthD.Button Four change height and width ” 相关考题
考题 有以下程序: included using namespace std; class Base { public: Base( ) { x=0; } 有以下程序:included<iostream>using namespace std;class Base{public:Base( ){x=0;}int x;};class Derived1:virtual public Base{public:Derived1( ){x=10;}};class Derived2:virtual public Base{public:Derived2( ){x=20;}};class Derived: public Derived1,protected Derived2{ };int main( ){Derived obj;cout<<obj. x<<endl;return 0;}该程序运行后的输出结果是______。

考题 importjava.awt.*;publicclassXextendsFrame{publicstaticvoidmain(Stringargs){Xx=newX();x.pack();x.setVisible(true);}publicX(){setLayout(newBordrLayout());Panelp=newPanel();add(p,BorderLayout.NORTH);Buttonb=newButton(North”);p.add(b):Buttonb=newButton(South”);add(b1,BorderLayout.SOUTH):}}Whichtwostatementsaretrue?()A.Thebuttonslabeled“North”and“South”willhavethesamewidth.B.Thebuttonslabeled“North”and“South”willhavethesameheight.C.Theheightofthebuttonlabeled“North”canveryiftheFrameisresized.D.Theheightofthebuttonlabeled“South”canveryiftheFrameisresized.E.Thewidthofthebuttonlabeled“North”isconstanteveniftheFrameisresized.F.Thewidthofthebuttonlabeled“South”isconstanteveniftheFrameisresized.

考题 下列程序用GridLayout布局管理器将Frame分为1行3列,并放入Button构件,横线处应填入的语句是( )。 import java.awt.*; public class Test { public static void main (String[] args) { Frame. frm=new Frame. ("GridLayout"); ____________ frm.add (new Button("Button1")); frm.add (new Button("Button2")); frm.add (new Button("Button3")); frm.setSize (300,300); frm.setVisible (true); } }A.frm.setLayout (GridLayout (1,3));B.setLayout (new GridLayout(1,3));C.frm.setLayout (new GridLayout(3,1));D.frm.setLayout (new GridLayout(1,3));

考题 下面程序的运行结果是()。includeclass Sample{int x, y;public:Sample() { x=y=0; 下面程序的运行结果是( )。#include<iostream.h>class Sample{int x, y;public:Sample() { x=y=0; }Sample(int a, int b) { x=a; y=b; }void (lisp(){cout<<"x="<<x<<",y="<<y<<end1;}};void main(){Sample s(2,3), *p=s;p->disp();}A.x=1, y=2B.x=2, y=4C.x=2, y=3D.x=4, y=3

考题 有如下程序;include using namespace std;class Base{public;Base(inti){x=i;}void d 有如下程序; #include <iostream> using namespace std; class Base { public; Base(inti){x=i;} void dispa0{cout<<x<<',';} private; int x; }; class Derived;public Base { public; Derived(int i);Base(i+10) {x=i;) void dispb(){dispa();cout<<x<<end1;} private; int x; }; int main() { Derived b(2) ; b.dispb(); return 0; } 运行的结果是( )。A.2,2B.12,2C.12,10D.10,2

考题 若有以下程序:includeusing namespace std;class data{public: int x; data(int x){ 若有以下程序: #include<iostream> using namespace std; class data { public: int x; data(int x) { data::x=x; } class A private: data dl; public: A(int x): dl(x){ } void dispaO cout<<dl.x<<","; } }; class B: public A { private: data d2; public: B(int x):A(x-1),d2(x){ } void dispb() { cout<<d2.x<<endl; } }; class C: public B { public: C(int x):B(x-1){ } void disp0 { dispa(); dispb(); } }; int main() { C obj(5); obj.disp(); return 0; } 程序执行后的输出结果是( )。A.5,5B.4,5C.3,4D.4,3

考题 类MyClas的定义如下: class MyClas{ public: MyClas(){} MyClas(int a){ value=new.int(i); } int *value; }; 若要对类中的value赋值,则下面的语句中正确的是( )A.MyClas x;x.value=10;B.MyClas x; *x.value=10;C.MyClas x;x. *value=10;D.MyClas x(10);

考题 阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。 【说明】 以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。 【Java代码】 interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}

考题 阅读下列说明和C++代码,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。 【说明】 以下C++代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分类及其关系如图6-1所示。 【C++代码】 #include?#include?using?namespace?std;class?DrawCircle?{??????//绘制圆形,抽象类? ? ? public: (1);//定义参数为?int?radius,?int?x,?inty? ?virtual~DrawCircle()?{?}};class?RedCircle:public?DrawCircle?{????//绘制红色圆形? ? ? ? public: void?drawCircle(intradius,?int?x,?int?y)?{cout??drawCircle?=?drawCircle;? }? ?virtual~shape()?{?}? public:? ?virtual?void?draw()?=?0;};class?Circle:public?Shape?{????//圆形? ? private:? ? ?int?x,y,radius;? ? public:? Circle(int?x,inty,int?radius,DrawCircle?*drawCircle)? (3)? {? this->x?=?x;? ?this->y?=?y;? ? this->radius?=?radius; }? ? ? public:? void?draw(){? drawCircle?-> (4); }};int?main(){Shape?*redCirclenew?Circle(100,100,10,????(5)????);//绘制红色圆形? Shape?*greenCircle=new?Circle(100,100,10, (6)??);//绘制绿色圆形redCircle >draw();? ?greenCircle?->draw();? ?return?0;}