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

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

4

B

8

C

12

D

16

E

18

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

}

}


正确答案:(1)Figure
(1)Figure 解析:类Rectangle继承自类Figure,所以此处填Figure。

第2题:

What is length (width, depth) of Hold No.1?


正确答案:The length (width, depth) of Hold No.1 is 40 (30, 15) meters.

第3题:

阅读下列程序说明和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);

}

}


正确答案:(1)i! =3
(1)i! =3 解析:当用户输入i为3时,需要结束循环,程序执行结束。

第4题:

有以下程序:include using namespace std;class A{private: int x,y;public: void se

有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。

A.8

B.4

C.35

D.70


正确答案:A
解析:本题考核成员对象的应用。类box的成员函数set()为设置对象的坐标值和对象的长、宽值。成员函数setarea返回该对象的面积。程序最后输出为8。

第5题:

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

}

}


正确答案:(1)Figure (2)height*width (3)Rectangle (4)super(widthwidth) (5)FiguTe
(1)Figure (2)height*width (3)Rectangle (4)super(width,width) (5)FiguTe 解析:本题以Java语言为载体,考查面向对象程序设计中的三个重要机制——继承、抽象类和动态绑定的应用。本题所解决的问题与试题6一样,有关的详细描述可参见试题6的分析。
在Java语言中通过在类中定义抽象方法来创建一个抽象类,或者直接将一个类声明为抽象类。
由于继承关系已经确定,所以第(1)、(3)、(5)空已经确定,分别为Figure、Rectangle和Figure。第(2)空应填height*widthn
Java中有一个特殊的函数super,用于在派生类中调用其基类的构造函数。利用 super,我们可以借助Rectangle的带有2个参数的构造函数将正方形的边长width传递到Rectangle的height和width中,所以第(4)空应填super(width,width)。

第6题:

下面程序运行时输出结果为______。 include include class Rect { public: Rect(int

下面程序运行时输出结果为______。

include<iostream.h>

include

class Rect

{

public:

Rect(int l, int w){length=l; width=w;)

void Print(){cout<<"Area:"<<length*width<<end1;}

void operator delete(void*p){free(p);}

private:

int length, width;

};

void main()

{

Rect *p;

p=new Rect(5, 4);

p->Print();

delete p;

}


正确答案:Area:20
Area:20 解析:此题考查的是内存空间的分配和释放,即free和delete函数的应用。使用new对某种类型的变量进行动态分配的语法格式为:指针=new类型;使用delete对动态分配的变量进行释放是:delete指针。此题中,首先为变量分配内存单元,然后执行语句p->Print();输出Area:20,然后利用delete释放内存单元。

第7题:

下面程序运行时输出结果为【】。 include include class Rect { public: Rec

下面程序运行时输出结果为【 】。

include<iostream.h>

include<malloc.h>

class Rect

{

public:

Rect(int1,int w)(length=1;width=w;)

void Print(){cout<<"Area:"<<length *width<<endl;)

void *operator new(size-t size){return malloc(size);}

void operator delete(void *p){free(p)

private:

int length,width;

};

void main()

{

Rect*p;

p=new Rect(5,4);

p->Print();

delete p;

}


正确答案:Area:20
Area:20

第8题:

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

}

}


正确答案:(1) Figure (2) height*width (3) rectangle (4) super(widthwidth) (5) Figure
(1) Figure (2) height*width (3) rectangle (4) super(width,width) (5) Figure 解析:本题考查Java编程。
Figure类是一个抽象类,其他三个类rectangle、square、triangle都要直接或间接继承该类,所以(1) (5)处应为“Figure”。(2)处是要计算矩形面积,矩形面积等于长乘以宽,所以(2)处应为“height*width”。正方形是一个特殊的矩形,所以可以继承矩形类,所以(3)处应为“rectangle”,(4)处应为“super(width,width)”。

第9题:

下列程序的执行结果为【 】。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)

}


正确答案:×
0 解析:注意本题不同于基类的指针指向派生类对象。Fun函数的形参是Point基类的引用。在可以用基类对象的地方,均可以用派生类替代,完成基类的行为。反之,在使用派生类对象的地方却不能用基类对象代替,这是因为派生类中的某些行为在基类对象中是不存在的。本题调用的是Point类对象的面积函数,其值永远为0。

第10题:

使用VC6打开考生文件夹下的工程test1_1,此工程包含一个源程序文件test1_1.cpp,但该程序运行有问题,请改正main函数中的错误,使该程序的输出结果如下:

Constructor called.

Default constructor called.

Area is 6

Area is 0

Area is 6

源程序文件test1_1,cpp清单如下:

include<iostream.h>

class RectAngle

{

private:

double ledge,sedge;

public:

RectAngle()

{

cout<<"Default constructor called.";

}

RectAngle(double l,double s)

{

ledge=l;sedge=s;

cout<<"Constructor called.";

}

void Set(double l,double s)

{

ledge=l;sedge=s;

}

void Area()

{

cout<<"Area is"<<ledge*sedge<<endl;

}

};

void main()

{

/***************** found *****************/

RectAngle Rect1(2,3);

RectAngle Rect2(1);

/**************** found *****************/

RectAnglC Rect3;

Rectl.Area();

/***************** found *****************/

RecL2.lodge=0;Rect2.sedge=0;

Reck2.Area();

Rect3.Area();

}


正确答案:(1)错误:Rect2(1) 正确:Rect2 (2)错误:Rect3 正确:Rect3(Rect1) (3)错误:Rect2.1edge=0;Rect2.sedge=0; 正确:Rect2.Set(00);
(1)错误:Rect2(1) 正确:Rect2 (2)错误:Rect3 正确:Rect3(Rect1) (3)错误:Rect2.1edge=0;Rect2.sedge=0; 正确:Rect2.Set(0,0); 解析:(1)主要考查考生对于重载构造函数调用的理解,Rect2应该调用缺省构造函数,这里重载的构造函数是以参数个数不同区分的;一个是缺省的构造函数,即没有参数的;另一个含有两个参数,为了能使“Default constructor called.”输出,应该调用不含有参数的缺省构造函数;
(2)主要考查考生是否会使用缺省的拷贝初始化构造函数,这是不出现构造函数被调用语句的惟一方法,不管使用缺省的构造函数还是含有两个参数的构造函数都会在屏幕上出现多余的文字,而这些文字只有使用在类中没有被定义的缺省拷贝初始化构造函数来声明一个新的对象才不会出现,根据提示应该使用Rect1这个已有的对象去初始化Rect3R个新的对象,这就是拷贝初始化构造函数的作用,即使用已有的或者已存在的对象去初始化一个新的对象;
(3)主要考查考生对于类的对象访问权限的掌握,ledge和sedge为类的私有成员,不能被类的对象Rect2访问,应使用成员函数Set()。

更多相关问题