查看文章
 
Delphi研发笔试试卷 我的小解
2010-01-15 16:11
Delphi研发笔试试卷 我的小解 研发笔试试卷(Delphi) 第一部分 Delphi知识 1. 如果一个元件希望放到IDE的元件面板上,它必须从___TComponent____类派生, 如果一个元件能作为其它元件的容器,它必须从_____TWinControl______类派生, 如果一个元件在运行时可见,它必须从________TGraphicControl_______类派生 (A)TGraphicControl (B)TWinControl (C)TComponent (D)TPersistent (E)TControl 写出TEdit、TLabel、TTimer的主要继承路径,答题格式TXXX->TXXX->...... TEdit: TObject->TPersistent->TComponent-> TControl-> TWinControl->TWidgetControl->TCustomEdit->TEdit TLabel: TObject->TPersistent->TComponent-> TControl-> TWinControl->TFrameControl->TCustomLabel-> TLabel TTimer: TObject->TPersistent->TComponent->THandleComponent 1) 为防止界面窗体“僵死”,可调用如下代码 A、Application.DoEvent B、Application.DoEvents C、Application.Idle DD、Application.ProcessMessages 2) 解释为什么? 答:让系统响应消息,有机会响应其它的事件了。 不让 application 的 process 把系统的资源给锁死(例如: cpu) 有如下类定义,请问类THouse的InstanceSize是__32___ TPoint = packed record X: Longint; Y: Longint; end; THouse = class private FOwner: string; ;//8 FPosition: TPoint; ;//8 FBounds: array[0..2] of Integer; ;//8 FLessees: TStrings; ;//4 public procedure Paint; ;//4 property Owner: string read FOwner; ;//0 end; A、24 B、28 C、32 D、40 常用的控件ListBox、ComboBox等都有BeginUpdate和 EndUpdate方法,请问他们的主要作用是什么? 答: 一次大量加入Item时,不显示界面加入过程,以提高导入速度 写SQL语句 如果有一个部门人员表BaseInfo,字段为ID,PID,Name(姓名),PID表示上下级关系: (1)分组查询:统计每个PID的记录数 ID 记录数 select PID, count(ID) as 下属人数 from BaseInfo group by PID (2)请做一个查询,得到以下结果(按姓名排序) ID 姓名 下属姓名 select 1 as id , (select name from BaseInfo where id =1) as 姓名,Name as 下属姓名 from BaseInfo where ID in (select ID from BaseInfo where PID= 1) order by 下属姓名 desc (3)在TSQL中使用事务需要用那些SQL关键字? 答: BEGIN TRANSACTION COMMIT ROLLBACK 解释一下Windows的消息机制和经典Windows应用程序的运作流程 答: 解释Delphi中“事件”的实现原理,如果你要为控件扩展一个自定义事件,你该怎么做? 答: Button1.OnClick := Form1.Button1Click; 定义一个Private 的 FonDo: TNotifyEvent= procedure(Sender: TObject) of object;//method pointer if Assigned(FonDo) then FonDo(Self);//第三步 为什么在TList中Add操作要比Insert操作快? 答: Add操作,TList只是在链表尾添加,O(1)的操作; Insert操作,要修改链表中间某位置前后记录的Link域的值 ,要从链表头开始是,是 O(n)的操作 10、某次调试中发现某树形控件响应很迟缓,经调试发现是如下语句,TreeView.Items.Clear执行缓慢,请分析可能的原因是什么? 答: 可能要析构TreeView.Items里的所有结点指向的对象 第二部分 Delphi编程 【编程】 给定一个文本文件(英文文章),统计其中各单词的频次。 Var Form1: TForm1; al: TIntegerList; strL: TStringList; Procedure TForm1.FormCreate(Sender: TObject); Begin al := TIntegerList.Create; strL := TStringList.Create; Memo1.Lines.LoadFromFile('d:\aaa.txt'); End; Procedure TForm1.FormClose(Sender: TObject; Var Action: TCloseAction); Begin al.Free; strL.Free; End; Var i, a: Integer; Procedure TForm1.Button1Click(Sender: TObject); Begin ListBox1.Clear; strL.Clear; al.Clear; a := 1; For i := 1 To Length(Memo1.Text) Do Begin If not (Memo1.Text In ['a'..'z', 'A'..'Z','0'..'9']) Then Begin If not (Memo1.Text[i-1] In ['a'..'z', 'A'..'Z','0'..'9']) Then Begin a := i+1; Continue; End; If strL.IndexOf(LowerCase(Copy(Memo1.Text, a, i - a))) > -1 Then Begin al.Items[strL.IndexOf(LowerCase(Copy(Memo1.Text, a, i - a)))] := al.Items[strL.IndexOf(LowerCase(Copy(Memo1.Text, a, i - a)))] + 1; a := i + 1; End Else Begin strL.Add(LowerCase(Copy(Memo1.Text, a, i - a))); al.Add(1); a := i+1 ; End; End; End; for i := 0 to strL.Count-1 do begin ListBox1.Items.Add(strL.Strings+' = '+ IntToStr(al.Items)) end; End;

类别:Delphi||添加到搜藏 |分享到i贴吧|浏览(353)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu