下列语句正确的有()A、%@ include file=”head.jsp”% B、% String url=”head.jsp”;%%@ include file=”url”% C、%@ include file=”head.jsp”?name=”lovo”% D、%String companyName=”lovo”;%%@include file”head.jsp”?name=‟companyName”%

题目

下列语句正确的有()

  • A、<%@ include file=”head.jsp”%> 
  • B、<% String url=”head.jsp”;%><%@ include file=”url”%> 
  • C、<%@ include file=”head.jsp”?name=”lovo”%> 
  • D、<%String companyName=”lovo”;%>%@include file”head.jsp”?name=‟companyName”% 
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下面程序的预设功能是:统计文件abc.txt中的字符个数。 include include

下面程序的预设功能是:统计文件abc.txt中的字符个数。

include <iostream.h>

include <fstream.h>

include <stdlib.h>

void main()

{

fstream file;

file.open( "abc.txt", ios::in);

if ( !file )

{

cout<<"Can not open abc.txt"<<end1;

abort();

}

char ch;

int i = O;

while (______________)

{

file.get(ch);

i++;

}

cout<<"Characters : "<<i<<end1;

file.close();

}

则程序中空白处应该填入的语句是【 】。


正确答案:!file.eof()
!file.eof() 解析:文件流对象的成员函数eof的功能是再进行输入操作时,若达到文件尾则返回true,否则返回false。程序的while循环中调用set()成员函数进行输入操作,循环结束的条件是操作到文件尾部。

第2题:

有以下程序: include include include intmain() {fstreamfil

有以下程序:

include <iostream.h>

include <fstream.h>

include <stdlib.h>

int main()

{

fstream filel,file2;

char line[100];

filel.open("source.txt",ios::in);

if(!file1)

{

cout<<"Can't open file source.txt!"<<end1;

abort();

}

file2.open("dest.txt",ios::out);

if(!file2)

{

cout<<"Can't open file dest.txt!"<<end1;

abort();

}

while(!file1.eof())

{

filel.getline(1ine,100);

file2<<line;

file2<<end1;

}

filel.close();

file2.close();

return 0;

}

此程序实现的功能是【 】。


正确答案:将文本文件source.txt中内容复制到文本文件dest.txt中
将文本文件source.txt中内容复制到文本文件dest.txt中 解析:程序首先将两个文件source和dest都打开,然后通过while循环,以一行为单位进行内容的复制。

第3题:

【C++代码】

#include <list>

#include <iostream>

#include <string>

using namespace std;

class AbstractFile{

protected:

string name; //文件或目录名称

public:

void printName(){cout<<name;} //打印文件或目录名称

virtual void addChild(AbstractFile *file)=0; //给一个目录增加子目录或文件}

virtual void removeChild(AbstractFile *file)=0; //删除一个目录的子目录或文件

virtual list<AbstractFile*> *getChildren()=0; //获得一个目录的子目录或文件

};

class File:public AbstractFile{

public:

File(string name) {(1) = name;}

void addChild(AbstractFile *file){return;}

void removeChild(AbstractFile *file){return;}

(2) getChildren(){return (3) ;}

};

class Folder :public AbstractFile{

private:

list <AbstractFile*> childList: //存储子目录或文件

public:

Folder(string name){ (4) name;}

void addChild(AbstractFile*file){childList.push_back(file);}

void removeChild(AbstractFile*file){childList.remove(file);}

list<AbstractFile*>*getChildren(){return (5) ;}

};

void main(){

//构造一个树形的文件/目录结构

AbstractFile *rootFolder=new Folder("c:\\ ");

AbstractFile*compositeFolder=new Folder("composite");

AbstractFile *windowsFolder=new Folder("windows");

AbstractFile*file=new File("TestCompositejava");

rootFolder->addChild(compositeFolder);

rootFolder->addChild(windowsFolder);

compositeFolder->addChild(file);


正确答案:
(1)this->name
(2)list<AbstractFile*>*
(3)NULL
(4)this->name
(5)&childList

第4题:

下列include命令中,正确的是()

A.#inclue[string.h]

B.#include{string.h}

C.#include(string.h)

D.#include


参考答案:D

第5题:

阅读下列说明和c++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。

【说明】

现欲构造一文件/目录树,采用组合(Composite)设计模式来设计,得到的类图如6—7所示:

【c++代码】

include<1ist>

include

include

using namespace std;

class AbstractFile{

protected:

string name;//文件或目录名称

public:

void printName(){cout<*getChildren()=0; //获得一个目录的子目录或文件

};

class File:public AbstractFile{

public:

File(string name){ (1) =name;)

void addChild(AbstractFile*file){return ;)

void removeChiid(AbstractFile*file){return;}(2) getChildren(){return ( 3 ) ;}

};

class Folder:public AbstractFile{

private:

listchildList; //存储子目录或文件

public:

Folder(string name){ (4) =name;}

void addChild(AbstractFile*file){childList.push back(file);}

void removeChiid(AbstractFile*file)(chiidList.remove(file);}

list*getChildren(){return (5) ;)

};

voidmain(){

//构造一个树形的文件/目录结构

AbstractFile*rootFolder=new Folder(“C:\\”);

AbstractFile*compositeFolder=flew Folder(”composite”);

AbstractFile*windowsFolder=new Folder(”windows”);

AbstractFile*file=new File(”TestComposite.java”);

rootFolder->addChild(compositeFolder);

rootFolder->addChild (windowsFolder);

compositeFolder->addChiid(file);

)


正确答案:(1)this一>name(2)list<AbstractFile*>*(3)NULL(4)this->name(5)&childList
(1)this一>name(2)list<AbstractFile*>*(3)NULL(4)this->name(5)&childList 解析:Composite模式定义:将对象以树型结构组织起来,以达成“部分一整体”的层次结构,使得客户端对单个对象和组合对象的使用具有一致性。Composite比较容易理解,想到Composite就应该想到树形结构图。组合体内这些对象都有共同接口,当组合体一个对象的方法被调用执行时,Composite将遍历(Iterator)整个树形结构,寻找同样包含这个方法的对象并实现调用执行。AbstractFile为一个抽象文件类,其作用主要是实现对文件或者文件夹的抽象。文件类File继承自AbstractFile。File(stringname)为File类的一个属性,用于获取文件名称。Addchild方法用来给一个目录增加子目录或文件。Removechild方法用于删除一个目录的子目录或文件。Getchildren方法用于获取一个目录或文件,所以返回值类型应该是一个列表形式的AbstractFile,但文件本身不包括子目录,故返回NULL。Fold类表示一个文件夹,属性Fold.er用于获取文件夹名称,Getchildren方法返回值应为List型的AbstractFile对象指针。

第6题:

有以下程序:includeincludeusing namespace std;int main(){fstream file;fi

有以下程序:

include<iostream>

include<fstream>

using namespace std;

int main()

{

fstream file;

file.open("abc.txt", ios :: in);

if ( !file )

{

cout<<"Can not open abc.txt"<<end1;

abort();

}

char buf[ 80 ];

int i = 0;

while (!file.eof())

{

file.getline(buf,80);

i++;

}

cout<<"Lines :"<<i<<end1;

file.close();

return 0;

}

程序实现的功能是【 】。


正确答案:统计文件abc.txt的行数
统计文件abc.txt的行数 解析:函数getline(char*s,streamsize n)从当前输入位置开始提取字符存入s所指向的具有n个字节的字符空间中。程序中这种调用方式是以换行符为结束标志输入字符序列,即输入一行字符(回车换行前的所有字符序列)。程序中通过while循环来统计abc.txt中行数。

第7题:

以下程序的执行结果是_______。 include include include void

以下程序的执行结果是_______。

include<iostream.h>

include<fstream.h>

include<stdlib.h>

void main()

{

char ch:

fstream file:

file.open("abc.dat",ios::out1ios::inlios::binary);

if(! file)

{

cout<<“abc.dat文件不能打开”<<endl:

abort


正确答案:25
25

第8题:

【Java代码】

import Java.util.ArrayList;

import java.util.List;

(1) class AbstractFile{

protected String name;

public void printName(){System.out.println(name);}

public abstract boolean addChild(AbstractFile file);

public abstract boolean removeChild(AbstractF ile file);

public abstract List<AbstractFile> getChildren();

class File extends AbstractFile{

public File(String name){this.name=name;}

public boolean addChild(AbstractFile file){return false;}

public boolean removeChild(AbstractFile file){return false;}

public List<AbstractFile> getChildren(){return (2) ;}

class Folder extends AbstractFile{

private List <AbslractFile> childList;

public Folder(String name){

this.name=name;

this.childList=new ArrayList<AbstractFile>();

public boolean addChild(AbstractFile file) { return childList.add(file);}

public boolean removeChild(AbstractFile file){return childList.remove(file);}

public (3) <AbstractFile> getChildren(){return (4) ;}

public class Client{

public static void main(String[] args){

//构造一个树形的文件/目录结构

AbstractFile rootFolder= new Folder("c:\\ ");

AbstractFile compositeFolder=new Folder("composite");

AbstractFile windowsFolder=new Folder("windows");

AbstractFile file=new File("TestComposite.java");

rootFolder.addChild(compositeFolder) ;

rootFolder.addChild(windowsFolder);

compositeFolder.addChild(file) ;

//打印目录文件树

printTree(rootFolder);

private static void printTree(AbslractFile ifile){

ifile.printName();

List <AbslractFile> children=ifile.getChildreno:

if(children==null) return;

for (AbstractFile file:children) {

(5) ;

}

该程序运行后输出结果为:

c:\

composite

TestComposite.java

Windows


正确答案:
(1)abstract
(2)null
(3)List
(4)childList
(5)printTree(file)

第9题:

使用VC6打开考生文件夹下的工程test14_3,此工程包含一个test14_3.cpp,其中定义了类File,但类的定义并不完整。请按要求完成下列操作,将程序补充完整。

(1)完成构造函数的定义,使数据成员filename,content指向为空。请在注释“//**1**”之后添加适当的语句;

(2)完成函数set_contents的定义,该函数为content申请新的空间来存储new_content的内容,成功返回true,失败返回false。请在注释“//**2**”之后添加适当的语句;

(3)完成成员函数copy(File & source,File & target)的定义,该函数实现将source的内容拷贝至target的功能,注意必须使用已经定义的成员函数来实现。请在注释“//**3**”之后添加适当的语句:

(4)完成析构函数的定义,要求释放content指向的空间。请在注释“//**4**”之后添加适当的语句。

输出结果如下:

file2:file1 contents

file2:file2 contents

注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。

源程序文件testl4—3.cpp清单如下:

include<iostream.h>

include<string.h>

class File{

private:

char file_name[64];

char*contents;

public:

File(char*filename)

{

// ** 1 **

};

File::~File()

{

// ** 4 **

}

void printfile(){cout<<file_name<<":"<<contents<<endl;)

friend bool copy(File & source,File & target);

bool set_contents(char * new_contents);

};

bool File::set_contents(char*new_contents)

{

// ** 2 **

if(contents==NULL)

return false;

strcpy(contents,new_contents);

return true;

}

bool copy(File & source,File & target)

{

// ** 3 **

}

void main{)

{

File f1("filel"),f2("file2");

f1.set_contents("filel contents");

copy(f1,f2);

f2.printfile();

f2.set_contents("file2 contents,);

f2.printfile();

}


正确答案:(1) strcpy(file_namefilename); contents=NULL; (2) contents=new char[(strlen(new_contents)+1)]; (3) return target.set contents(source.contents); (4) delete[]contents;
(1) strcpy(file_name,filename); contents=NULL; (2) contents=new char[(strlen(new_contents)+1)]; (3) return target.set contents(source.contents); (4) delete[]contents; 解析:主要考查点为类的构造函数的定义、字符串函数的使用及动态空间的申请与释放等,注意字符串函数的使用,其中strlen返回字符串含有字符的数目,strcpy是将参数2的字符串赋值给参数1的字符串。

第10题:

下列#include命令中,正确的是()

  • A、#inclue[string.h]
  • B、#include{string.h}
  • C、#include(string.h)
  • D、#include

正确答案:D

更多相关问题