1) byte 类型的范围是
a) -128 to 127
b) (-2 power 8 )-1 to 2 power 8
c) 0 to 255
d) 依赖于虚拟机的不同而不同
2) char 类型的范围是
a) -128 to 127
b) (-2 power 8 )-1 to 2 power 8
c) -255 to 256
d) 依赖于虚拟机的不同而不同
3) 以下哪一些是Delphi的关键字
a) if
b) then
c) goto
d) while
e) case
f) break
4) 以下哪些变量命名是符合规则的
a) 2variable
b) variable2
c) _whatavariable
d) 变量1
e) $anothervar
f) #myvar
5) 以下程序的返回值是什么
function caseOfTest : string ;
var i : integer;
begin
Result := '';
for i := 1 to 3 do
begin
case i of
0 :
begin
Result := Result + '0,';
Break;
end;
1 :
Result := Result + '1,';
2 :
begin
Result := Result + '2,';
Break;
end;
else
Result := Result + 'x,';
end;
end;
end;
a) 1,2,2,x,
b) 1,2,
c) 1,2,x,
d) 0,1,2,x,
6) 以下程序返回结果是什么
function ifTest:string;
var i:integer;
function plusplus(var i:integer):integer;
begin
Result := i;
Inc(i);
end;
begin
i := 4;
Result := '';
if(plusplus(i)>=8)or(plusplus(i)>=7)or(plusplus(i)>=6)or
(plusplus(i)>=5)or(plusplus(i)>=4)or(plusplus(i)>=3)or
(plusplus(i)>=2)or(plusplus(i)>=1)or(plusplus(i)>=0) then
begin
Result := Format('%d',[i]);
end;
end;
a) 0
b) 1
c) 2
d) 3
e) 4
f) 5
g) 6
h) 7
i) 8
已知,有代码如下:
Type
TClassA = class
Public
Function funcTest:String;
Function funcBase:String;
End;
TClassB = class(TClassA)
Public
Function funcTest:String;
End;
Implementation
Function TClassA.funcBase:String;
Begin
Result := funcTest;
End;
Function TClassA.funcTest:String;
Begin
Result := 'function in ClassA';
End;
Function TClassB.funcTest:String;
Begin
Result := 'function in ClassB';
End;
Procedure protest;
Var b:TClassB;
Begin
b := TClassB.Create;
ShowMessage(Format('%d: %s'#13#10'%d: %s',
[1,b.funcTest,2,TClassA(b).funcTest]));
b.Free;
End;
Procedure protest2;
Var b:TClassB;
Begin
b := TClassB.Create;
ShowMessage(Format('%d: %s'#13#10'%d: %s',
[1,b.funcBase,2,TClassA(b).funcBase]));
b.Free;
End;
7) Protest的输出结果为:
a) 1: function in ClassA
2: function in ClassA;
b) 1: function in ClassB
2: function in ClassA;
c) 1: function in ClassB
2: function in ClassB;
d) 1: function in ClassA
2: function in ClassB;
8) Protest2的输出结果为:
a) 1: function in ClassA
2: function in ClassA;
b) 1: function in ClassB
2: function in ClassA;
c) 1: function in ClassB
2: function in ClassB;
d) 1: function in ClassA
2: function in ClassB;
接上题
Type
TClassA = class
Public
Function funcTest:String;virtual;
Function funcBase:String;
End;
TClassB = class(TClassA)
Public
Function funcTest:String;override;
End;
9) Protest的输出结果为:
a) 1: function in ClassA
2: function in ClassA;
b) 1: function in ClassB
2: function in ClassA;
c) 1: function in ClassB
2: function in ClassB;
d) 1: function in ClassA
2: function in ClassB;
10) Protest2的输出结果为:
a) 1: function in ClassA
2: function in ClassA;
b) 1: function in ClassB
2: function in ClassA;
c) 1: function in ClassB
2: function in ClassB;
d) 1: function in ClassA
2: function in ClassB;
11) 程序题
已知数据库中有表tbl_test_4delphi(id varchar2(20) primary key, title varchar2(40) not null, level integer, fid varchar2(20) not null),其中根ID为’ROOTID’。请补充程序实现以下功能:在tvTitles(TTreeView)中按照数据间的关系显示数据标题。
Procedure showTitles(tvTitles:TTreeView;Con:TADOConnection);
const strSql = 'SELECT id, Title FROM tbl_test_4delphi WHERE fid = :p1 ORDER BY level DESC';
Procedure showSubTitles(fid:string;parentNode:TTreeNode);//递归方法
Var qry:TADOQuery;
//在此处添加需要用到的变量声明
Begin
Qry := TADOQuery.create(nil);
Try
Qry.connection := Con;
////////请在此添加代码
Finally
Qry.free;
End;
End;
Var node:TTreeNode;
Begin
tvTitles.Items.BeginUpdate;
tvTitles.Items.Clear;
node := tvTitles.Items.Add(nil,'root');
showSubTitles('ROOTID',node);
tvTitles.Items.EndUpdate;
End;
12) 计算输入数值以内的质数,并且显示在Memo中。
说明:
number 输入 整型 表明计算范围
返回值 输出 整型 计算范围内质数的数量
num 变量 布尔型数组 num[index]表示index是否为质数(0,1为false)
思路:
从2开始判断num[index]是否为质数,否则判断index + 1,是则将所有num[n*index]标记为false(n in [2..number - 1]),一直计算到number – 1。
function calcPrime(number:integer;memo:TMemo):integer;
var num:array of Boolean;
i,index:integer;
//请添加需要的声明
Begin
Result := 0;
memo.Lines.Clear;
memo.Lines.Add(Format('%d 以内的质数有:',[number]));
//请补充代码
i := 0;
Memo.Lines.Add('');
For index := 2 to number - 1 do
If num[index] then
begin
if i = 8 then //每行显示8个数字
begin
i := 0;
Memo.Lines.Add('');
end;
Memo.Lines[Memo.Lines.Count - 1] :=
Memo.Lines[Memo.Lines.Count - 1]
+ Format('%8d',[index]);
Inc(i);
Inc(Result);
end;
end;
13) Object Pascal语言中包含哪几类成员?成员的可见性有哪几个级别?
14) 已知属性Property myProperty : integer read FMyProperty write FMyProperty default 20;其中“default 20”表示什么?
嘿嘿