题目详情

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

【说明】

某图像预览程序要求能够查看BMP、JPEG和GIF三种格式的文件,且能够在Windows和Linux两种操作系统上运行。程序需具有较好的扩展性以支持新的文件格式和操作系统。为满足上述需求并减少所需生成的子类数目,现采用桥接模式进行设计,得到如图6-1所示的类图。

初级程序员,押题密卷,2021年程序员押题密卷3

【Jave代码】

Import java.util.*;class Matrix{ //各种格式的文件最终都被转化为像素矩阵//此处代码省略};abstract class Implementor{Public( );//显示像素矩阵 m};class WinImp extends Implementor{public void doPaint(Matrix m){//调用Windows 系统的绘制函数绘制像素矩阵}};class LinuxImp extends Implementor{public void doPaint(Matrix m){//调用Linux 系统的绘制函数绘制像素矩阵}};abstract class Image{public void setImp(Implementor imp){this.imp= imp; }public abstract void parseFile(String fileName);protected Implementor imp;};class BMPImage extends Image{//此处代码省略};class GIFImage extends Image{public void parseFile(String fileName) {//此处解析BMP 文件并获得一个像素矩阵对象 m( );//显示像素矩阵 m}};Class Main{Public static viod main(String[]args){//在Linux 操作系统上查看 demo.gif 图像文件Image image=()Implementor imageImp=()( )Image.parseFile(〝demo.gif〝);}}

正确答案及解析

正确答案
解析

1. abstract void doPaint(Matrix m)

2. imp.doPaint(m)

3. new GIFImage()

4. new LinuxImp()

5. image.setImp(imageImp)

包含此试题的试卷

你可能感兴趣的试题

单选题

(  )is the process of transforming information so it is unintelligible to anyone but the intended recipient.

  • A.Encryption
  • B.Decryption
  • C.Security
  • D.Protection
查看答案
单选题

As each application module is completed,it undergoes(  )to ensure that it operates correctly and reliably.

  • A.unit testing
  • B.integration testing
  • C.system testing
  • D.acceptance testing
查看答案
单选题

(  )algorithm specifies the way to arrange data in a particular order.

  • A.Search
  • B.Random
  • C.Sorting
  • D.Merge
查看答案
单选题

After analyzing the source code,(  )generates machine instructions that will carry out the meaning of the program at a later time.

  • A.an interpreter
  • B.a linker
  • C.a compiler
  • D.a converter
查看答案
单选题

(  )can help organizations to better understand the information contained within the data and will also help identify the data that is most important to the business and future business decisions.

  • A.Data processing system
  • B.Big Data analytics
  • C.Cloud computing
  • D.Database management
查看答案

相关题库更多 +