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

题目内容 (请给出正确答案)

以下是类Rectangle的定义: class Rectangle: def __init__(self,width,height): self.width=width self.height=height def getPerimeter(self): return 2*(self.width+self.height)变量r1是Rectangle的对象,获得r1的周长的语句是________。

A.print(r1.getPerimeter())

B.print(r1)

C.print(getPerimeter(r1))

D.print(self.getPerimeter())


参考答案和解析
print(r1.getPerimeter())
更多 “以下是类Rectangle的定义: class Rectangle: def __init__(self,width,height): self.width=width self.height=height def getPerimeter(self): return 2*(self.width+self.height)变量r1是Rectangle的对象,获得r1的周长的语句是________。A.print(r1.getPerimeter())B.print(r1)C.print(getPerimeter(r1))D.print(self.getPerimeter())” 相关考题
考题 阅读下列程序说明和C代码,把应填入其中n处的字句写在对应栏内。【说明】下面的程序能够计算不同图形的面积。程序中把每个图形的数据定义成结构类型,利用共同体类型描述2种图形的数据。程序根据输入参数代表的图形类型,求出图形的面积并输出。【程序】struct Circle{float x,y; /*圆心位置*/float r; /*圆半径*/};struct Rectangle{float width; /*矩形宽*/float length; /*矩形长*/};union shape{struct Circle circle;/*圆数据结构*/struct Rectangle rectangle;/*矩形数据结构*/};main(){union shape a;float area;int i;printf(“input number: 1circle,2rectangle,3 end\n”);scanf("%d",i);while (1) /*循环接收输入,并计算输出*/{switch(i){case 1:printf(“input radius:\n”);scanf(“%f”, (2);/*共同体类型变量接收输入*/area=3.1415926* (3);printf(“the area of circle=%f\n”,area);break;case 2:printf(“input width and length :\n”);seanf(“%f,%f”, (4);/*共同体类型变量接收输入*/。area=(5);printf(“the area of rectangle=%f\n”,area);break;}printf(“input number:1 circle,2 rectangle,3 end\n”);scanf(“%d”,i);}}

考题 ●试题六阅读以下说明和C++程序,将应填入(n)处的语句写在答题纸的对应栏内。【说明】以下程序的功能是计算三角形、矩形和正方形的面积并输出。程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述3种图形面积的通用接口【C++程序】#includeiostream.h#includemath.hclass Figure{public:virtual double getArea()=0:∥纯虚拟函数};class Rectangle: (1) {protected:double height;double width;public:Rectangle(){};Rectangle(double height,double width){this-height=height;this-width=width;}double getArea(){return (2) ;}};class Square: (3) {public:Square(double width){(4) ;}};class Triangle: (5) {double la;double Ib;double lc;public:Triangle(double la,double lb,double lc){This-la=la;this-lb=lb;this-lc=lc;}double getArea(){double s=(la+lb+±c)/2.0;return sqrt(s*(s-1a)*(s-1b)*(s-1c));}};void main(){Figure*figures[3]={new Triangle(2,3,3),new Rectangle(5,8),new SqUare (5) );for (int i=0;i3;i++){cout"figures["i"]area="(figures[i])-getArea()endl;}}

考题 阅读以下说明和Java程序,将应填入(n)处的字句写在对应栏内[说明]以下程序的功能时三角形、矩形和正方形的面积输出。程序由5个类组成:areatest是主类,类Triangle,Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算面积的抽象方法。[Java程序]public class areatest {public static viod main(string args[]){Figure[]Figures={New triangle(2,3,3),new rectangle(5,8),new square(5)};for(int i=0; i<Figures.length;i++){system.out.println(Figures+"area="+Figures.getarea());}}}public abstract class figure {public abstract double getarea();}public class rectangle extends (1) {double height;double width;public rectangle (double height,double width){this.height=height;this.width=width;}public string tostring(){return"rectangle:height="+height+",width="+width+":";}public double getarea(){return (2)}}public class square exends (3){public square(double width){(4);}public string tostring(){return"square:width="+width":";}}public class triangle entends (5){double la;double lb;double lc;public triangle(double la,double lb,double lc){this.la=la;this.lb=lb;this.lc=lc;}public string tostring()(return"triangle:sides="+la+","+lb+","+lc+":";}public double get area(){double s=(la+lb+lc)/2.0;return math.sqrt(s*(s-la)*(s-lb)*(s-lc));}}

考题 阅读以下说明和Java源程序,将应填入(n)处的字句写在对应栏内。【说明】以下程序能够计算三角形、矩形和正方形的周长并输出。程序由5个类组成:AreaTest是主类,类Triangle、Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算周长的抽象方法。【程序】public class girthTest{public static void main (String args[]){Figure[]figures={new Triangle (2,3,3),new Rectangle(5,8),new Square(5)};for(int i=0;i<figures.length;i++){System.out.println(figures[i]+"girth="+figures[i].getGirth());}}}public abstract class Figure{public abstract double getGirth();}public class Rectangle extends (1) {double height;double width;public Rectangle(double height,double width){this.height=height;this.width=width;}public String toString(){return "Rectangle:height="+height+",width="+width+":";}public double getGirth(){return (2);}}public class Square extends (3) {public Square(double width){(4);}public Stdng toString(){return "Square:width='+width+":";}}public class Triangle extends (5) {double la;double lb;double lc;public Triangle(double la,double lb,double lc){this.la=la;this.lb=lb;this.lc=lc;}public String toString(){return "Triangle:sides=" +la+"," +lb+"," +lc+":";}public double getGirth(){return la+lab+lc;}}

考题 ( 23 )为了将 HelloApplet( 主类名为 HelloApplet.class) 嵌入在 greeting.html 文件中,应该在下列 greeting.html 文件的横线处填入的代码是 HTML HEADTITLE Greetings /TITLE/HEADBODYAPPLET ______/APPLET/BODY/HTMLA) HelloApplet.classB ) CODE= ” HelloApplet.class ”C ) CODE= ” HelloApplet.class ” WIDTH=150 HEIGHT=25D ) CODE= ” HelloApplet.class ” WIDTH=10 HEIGHT=10

考题 以下代码片断中,属于绝对定位的是()。A、#box{width:100px;height:50px;position:absolute;}B、#box{width:100px;height:50px;position:static;}C、#box{width:100px;height:50px;position:relative;}D、#box{width:100px;height:50px;}

考题 阅读以下说明和C++代码,将应填入(n)处的字句写在对应栏内。【说明】以下C++程序的功能是计算三角形、矩形和正方形的面积并输出。程序由4个类组成:类 Triangle、Rectangle和Square分别表示三角形、矩形和正方形:抽象类Figure提供了一个纯虚函数getAxea(),作为计算上述3种图形面积的通用接口。【C++代码】include<iostream>include<cmath>using namespace std;class Figure{public:virtual double getArea()=0;//纯虚函数};class Rectangle : (1) {protected:double height;double width;public:Rectangle(){}Rectangle(double height, double width){this->height=height;this->width=width;}double getArea(){return (2);}};class Square: (3) {public:Square(double width){(4);}};class Triangle: (5) {private:double la,lb,lc;public:Triangle(double la,double lb,double lc){this->la=la;this->1b=1b;this->lc=lc;}double getArea(){double s=(la+lb+lc)/2.0;return sqrt(s*(s-la)*(s-lb)*(s-lc));}int main(){Figure *figures[3]={new Triangle(2,3,3),new Rectangle(5,8), new Square(5)};for(int i=0;i<3;i++){cout<<"figures["<<i<<"]area="<<(figures[i])->getArea()<<endl;}return 0;}

考题 使用VC6打开考生文件夹下的工程test41_3。此工程包含一个test41_3.cpp,其中定义了类Rectangle,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。(1)定义类Rectangle的私有数据成员left,top和fight,bottom,它们都是int型的数据。请在注释“//**1**”之后添加适当的语句。(2)添加类Rectangle的带四个int型参数1、t、r、b的构造函数的声明,并使这四个参数的默认值均为0,请在注释“//**2**”之后添加适当的语句。(3)添加类Rectangle的成员函数SetTop()参数为int型的t,作用为把t的值赋给类的数据成员top,添加类Rectangle的成员函数SetBottom()参数为int型的t,作用为把t的值赋给类的数据成员bottom,请在注释“//**3**”之后添加适当的语句。(4)完成派生类Rectangle的成员函数Show()的定义,使其以格式“right-bottom point is(right,bottom)”输出,请在注释“//**4**”之后添加适当的语句。源程序文件test41_3.cpp清单如下:include <iostream.h>class Rectangle{// ** 1 **int right, bottom;public:// ** 2 **~ Rectangle(){};void Assign(int 1, int t, int r, int b);void SetLeft(int t){left = t;}void SetRight(int t){right = t;}// ** 3 **void SetBottom(int t){bottom = t;}void Show();};Rectangle::Rectangle(int 1, int t, int r, int b){left = 1; top = t;right = r; bottom = b;}void Rectangle::Assign(int 1, int t, int r, int b){left = 1; top = t;right = r; bottom = b;}void Rectangle::Show(){cout<<"left-top point is ("<<left<<","<<top<<")"<<'\n';// ** 4 **}void main(){Rectangle rect;rect.Show();rect.Assign(100,200,300,400);rect.Show();}

考题 下面程序段中,说法正确的是( ) 。class location{ public : int GetX(); }; class rectangle:private location { public: int GetW(); }; A.类rectangle的私有派生类是locationB.类rectangle中的public成员在类location中是私有的C.类location中的public成员在类rectangle中是不可访问的D.viodf(){Rectangler;intX=r.GetX();}其中intX=r.GetX();是非法语句

考题 阅读以下说明和C++代码,填入(n)处。[说明]以下C++代码使用虚函数实现了同一基类shape派生出来的Class rectangle、Class triangle、Class circle实现了计算矩形、圆形面积的计算。仔细阅读以下代码,将(n)处语句补充完整。[代码5-1]include<iostream.h>define PI 3.14159class shape {//基类protected:(1);public:(2);(3);};[代码5-2]class rectangle: public shape {public:rectangle (int x2,int y2,int r2): (4) {};double area ( ) {return x*y; };};class circle: public shape {public:circle (int x3,int y3,int r3):(5){};double area ( ) {return r*r*PI; };};[代码5-3]void main ( ){rectangle r (10,20,0);circle c (0,0,30);shape (6);cout<<"长方形面积="<<s1->area ( ) <<endl;cout<<"圆形面积="<<s2->area ( ) <<endl;}[运行结果]长方形面积=200圆形面积=2827.43

考题 使用VC6打开考生文件夹下的工程test36_3。此工程包含一个test36_3.cpp,其中定义了类CRectangle,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。(1)定义类CRectangle的数据成员width和height,它们都是int型的数据。请在注释“//**1**”之后添加适当的语句。(2)添加类CRectangle的友元函数duplicate()的声明,其返回值类型和参数类型均为Crectangle的,请在注释“//**2**”之后添加适当的语句。(3)完成类Crectangle的成员函数set_values的定义,把传入的参数a和b分别赋值为数据成员width和height,请在注释“//**3**”之后添加适当的语句。(4)完成派生类Crectangle的友元函数duplicate的定义,把函数中的临时对象rectres的值返回主函数,请在注释“//** 4**”之后添加适当的语句。注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test36_3.cpp清单如下:include <iostream.h>class CRectangle{// ** 1 **public:void set_values (int, int);int area (void) {return (width * height);}// ** 2 **};void CRectangle::set_values (int a, int b){// ** 3 **}CRectangle duplicate (CRectangle rectparam){CRectangle rectres;rectres.width = rectparam.width*2;rectres.height = rectparam.height*2;// ** 4 **}void main ( ){CRectangle rect, rectb;rect.set_values (2,3);rectb - duplicate (rect);cout << rectb.area()<<end1;}

考题 阅读以下说明和C++程序,将应填入(n)处的语句写在的对应栏内。【说明】以下程序的功能是计算三角形、矩形和正方形的面积并输出。程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述3种图形面积的通用接口。【C++程序】include<iostream.h>include<math.h>class Figure {public:virtual double getArea()=0; //纯虚拟函数};class Rectangle:(1){protected:double height;double width;public:Rectangle() {};Rectangle(double height,double width) {this->height=height;this->width=width;}double getArea() {return (2);}};class Square:(3){public:Square(double width){(4);}};class Triangle:(5){double la;double lb;double lc;Public:Triangle(double la, double lb, double lc) {This->la=la; this->lb=lb; this->lc=lc;}double getArea() {double s = (la+lb+±c)/2.0;return sqrt(s,(s-la)*(s-lb)*(s-Ic));}};void main() {Figure*figures[3]={new Triangle(2,3,3), new Rectangle(5,8), new SqUare(5));for(int i=0;i<3;i++){cout<<"figures["<<i<<"]area="<<(figures[i])->getArea()<<endl;}}

考题 阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】以下C++程序的功能是计算三角形、矩形和正方形的面积并输出。程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述3种图形面积的通用接口。include<iostream.b>include<math.h>class Figure{public:virtual double getArea0=0; //纯虚拟函数};class Rectangle: (1) {protected:double height;double width;public:Rectangle(){};Rectangle(double height, double width){This->height=height;This->width=width;}double getarea(){return (2);}};class Square: (3) {public:Square(double width){(4);}};class Triangle: (5) {double la;double lb;double lc;public:Triangle(double la, double lb, double lc){this->la=la; this->lb; this->lc;}double getArea(){double s=(la+lb+lc)/2.0;return sqrt(s*(s-la)**(s-lb)*(s-lc));}};viod main(){Figure* figures[3]={new Triangle(2,3,3), new Rectangle(5,8), new Square(5));for(int i=0;i<3;i++){cout<<"figures["<<i<<"]area="<<(figures[i])->getarea()<<endl;}}

考题 阅读以下说明和Java源程序,将应填入(n)处的字句写在答题纸的对应栏内。说明以下程序的功能是计算三角形、矩形和正方形的面积并输出。程序由5个类组成:AreaTest是主类,类Triangle、Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算面积的抽象方法。程序public class AreaTest{public static void main(String args[]){Figure[]figures={new Triangle(2,3,3),new Rectangle(5,8), new Square(5)};for(int i=0;i<figures.1ength;i++){System.out.println(figures[i]+"area="+figures[i].getArea());}}}public abstract class Figure{public abstract double SetAJea();public class Rectangle extends (1) {double height;double width;public Rectangle(double height,double width){this.height=height;this.width=width;}public String toString(){return "Rectangle:height="+height+",width="+width+":";}public double getArea() { return (2);} } public class Square extends (3) {public Square(double width) {(4);}public String toString() {return "Square:width="+width+":";} } public class Triangle extends (5). {double la;double lb;double lc;public Triangle(double la,double lb,double lc) {this.la=la; this.lb=lb; this.lc=lc;public String toString(){return "Triangle: sides="+la+","+lb+","+lc+":";public double getArea() {double s=(la+lb+lc)/2.0;return Math.sqrt(s*(s-la)*(s-lb)*(s?1c));}}

考题 如下程序声明了一个二维图形类TwoDShape,从其派生出矩形类Rec。 include include 如下程序声明了一个二维图形类TwoDShape,从其派生出矩形类Rec。include<iostream>include<string>using namespaee std,class TwoDShape{// 二维图形类char name[20];public:TwoDShape (char * n="unknown") {strcpy(name, n);}Char * getName(){return name;}【 】=0;};class Rec: public TwoDShape{double width, heightpublic:Rec(double w-=0. 0,double h=0. 0):TwoDShape("rectangle"){ width=w; height=h; }double getWidth() {return width;}double getHeight() {return height;}double area() {return width * height;}};int main() {TwoDShape * shape;Shape=new Rec(2.1,3.0);cout<<"object is"<<shape->getName()<<"\n";cout<<"Area is"<<shape->area()<<"\n";return 0}请将程序补充完整,使程序在运行时输出:abject is triangleArea is 6.3

考题 下列程序的执行结果为【 】。include class Point{public:Point(double i, double j) 下列程序的执行结果为【 】。include <iostream. h>class Point{public:Point(double i, double j) { x=i; y=j;}double Area() const { return 0.0;}private:double x, y;};class Rectangle: public Point{public:Rectangle(double i, double j, double k, double 1)double Area() const {return w * h;}private:double w, h;};Rectangle: :Rectangle(double i, double j, double k. double 1): Point(i,j).{w=k, h=1}void fun(Point s){cout<<s. Area()<<end1;}void main( ){Rectangle rec(3.0, 5.2, 15.0. 25.0);fun(rec)}

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。说明以下程序的功能是计算三角形、矩形和正方形的面积并输出。程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述三种图形面积的通用接口。c++程序include <iostream.h>inclule <math.h>class Figure {public:virtual double getArea()= 0; // 纯虚拟函数};class Rectangle: (1) {protected:double height;double width;public:Rectangle() { };Rectangle(double height, double width) {this->height = height;this->width = width;}double getArea() {return (2) ;}class Square: (3) {public:Square(double width) {(4) ;}};class Triangle: (5) {double la;double lb;double lc;public:Triangle(double la, double lb, double lc) {this->la = la; this->lb ='lb; this->lc = lc;}double getArea() {double s = (la+lb+lc)/2.0;return sqrt(s*(s-la)*(s-lb)*(s-lc));} }; void main() {Figure* figures[3] = {new Triangle(2,3,3), new Rectangle(5,8), new Square(5)};for (int i = 0; i < 3; i++) {com << "figures[" << i << "] area =" << (figures[i])->getArea0 << endl;}

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内[说明]以下程序的功能是计算三角形、矩形和正方形的面积并输出。程序由4个类组成:类Triangle,Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述三种图形面积的通用接口。[C++程序]include<iostream.h>include<math.h>class Figure{public:virtual double getArea()=0; //纯虚拟函数};class Rectangle: (1) {protected:double height;double width;public:Rectangle(){};Rectangle(double height,double width){This->height=height;This->width=width;}double getarea(){return (2);}};class Square: (3)public:square(double width){(4);}};class triangle: (5) {double la;double lb;double lc;public:triangle(double la,double lb,double lc){this->la=la;thiS->ib;this->lc;}double getArea(){double s=(la+lb+lc)/2.0;return sqrt(s*(s-la)**(s-lb)*(s-lc));}};viod main(){figure*figures[3]={new triangle(2,3,3),new Rectangle(5,8),new Square(5)};for(int i=0; i<3;i++){cout<<"figures["<<i<<"]area="<<(figures)->getarea()<<endl;}}};

考题 图像在网页显示的代码正确的是()A、<img src="Images/exit.gif"width="69"height="24"B、<imges src="exit.gif"width="69"height="24"C、<img url="Images/exit.gif"width="69"height="24"D、<imge src="Images/exit.gif"width="69"height="24"

考题 以下关于width属性和height属性语法格式正确的是()。A、width:15;B、width:60px;C、height:100%;D、height:100;

考题 以下定位,脱离文档流的是()。A、#box{width:100px ;height:50px;}B、#box{width:100px ;height:50px; postion:absolute}C、#box{width:100px ;height:50px; postion:relative}D、#box{width:100px ;height:50px; position:static}

考题 Which statements concerning the effect of the statement gfx.drawRect(5, 5, 10, 10) are true, given that gfx is a reference to a valid Graphics object?()  A、The rectangle drawn will have a total width of 5 pixels.B、The rectangle drawn will have a total height of 6 pixels.C、The rectangle drawn will have a total width of 10 pixels.D、The rectangle drawn will have a total height of 11 pixels.

考题 单选题The length of a rectangle is 5 more than the side of a square, and the width of the rectangle is 5 less than the side of the square. If the area of the square is 45, what is the area of the rectangle?A 20B 25C 45D 50E 70

考题 问答题A rectangle is equal in area to a square with sides of length 12. Is the diagonal of the rectangle greater in length than 20?  (1) The rectangle has a length of 16.  (2) The rectangle has a width of 9.

考题 单选题The base of a rectangle is two times as long as the height. If the perimeter is 42, what is the area of the rectangle?A 36B 42C 98D 196E 218

考题 单选题Which statements concerning the effect of the statement gfx.drawRect(5, 5, 10, 10) are true, given that gfx is a reference to a valid Graphics object?()A The rectangle drawn will have a total width of 5 pixels.B The rectangle drawn will have a total height of 6 pixels.C The rectangle drawn will have a total width of 10 pixels.D The rectangle drawn will have a total height of 11 pixels.

考题 单选题If the area of a square with sides of length 8 centimeters is equal to the area of a rectangle with a width of 4 centimeters, what is the length of the rectangle, in centimeters?A 4B 8C 12D 16E 18

考题 单选题以下代码片断中,属于绝对定位的是()。A #box{width:100px;height:50px;}B #box{width:100px;height:50px; position:absolute;}C #box{width:100px;height:50px; position:static;}D #box{width:100px;height:50px; position:relative;}