1.
知学生关系:R(学号,姓名,系名称,系地址),每一名学生属于一个系,每一个系有一个地址,则R规范化程度属于___ ___2NF(2分)
2.
P地址为 140.111.0.0 的B类网络,若要切割为9个子网,而且都要 连上Internet,请问子网掩码设为(D )。(3分)
A. 255.0.0.0
B. 255.255.0.0
C. 255.255.128.0
D. 255.255.240.0
3.
当关系R和S做自然联接时,能够保留R中不满足连接条件记录的操作是 ( A )(3分)
A.左外联接 B.右外联接 C.内部连接 D.全外联接
4.
开发与运行Java程序需要经过的三个主要步骤为 、
和 。
编辑源程序、编译生成字节码、解释运行字节码(6分)
5.
谈谈作用域public,private,protected,以及不写时的区别?(12分)
作用域 当前类 同一package 子孙类 其他package
public √ √ √ √
protected √ √ √ ×
friendly √ √ × ×
private √ × × ×
不写时默认为friendly
写个程序,要求创建一个文件,写入从键盘输入的一串字符,然后再读该文件并将文件内容显示在屏幕上。(18分)
import java.io.*;
class MyFileIo{
public static void main(String args[]){
FileInputStream fin;
FileOutputStream fout;
char ch;
int data;
try{
fin = new FileInputStream(FileDescriptor.in);
fout = new FileOutputStream(“myfile1”);
System.out.println(“请输入一串字符以#结束:”);
while((ch = (char)fin.read()) != ‘#’)
Fout.write(ch);
fin.close();
fou.close();
System.out.print(“”);
fin = new FileInputStream(“myfile1”);
fout = new FileOutpurStream(FileDescriptor.out);
while(fin.available() > 0){
data = fin.read();
fou.write(data);
}
fin.close();
fout.close();
}catch(FileNotFoundException e){
System.out.println(“File not found!”);
}carch(IOException e){}
}
}