2009年10月7日 星期三
20091007計概小考
20091007計概小考
第一題 50分
WPF的程式是利用兩個.xaml檔,來產生四個.cs檔。App.xaml用來產生App.xaml.cs以及App.g.i.cs,這兩個cs檔分別定義了一部分的class App,兩個cs檔合起來,形成一個完整的class App。
App.xaml 如下示
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"
>
App.g.i.cs如下示:
using System;
using System.Windows;
public partial class App : Application
{
[STAThread()]
public static void Main()
{
TestApplication.App app = new TestApplication.App();
app.InitializeComponent();
app.Run();
}
public void InitializeComponent()
{
this.StartupUri = new Uri("Window1.xaml", System.UriKind.Relative);
}
}
請繪圖說明當Main()的第二個指令執行完畢時,相關的變數配置情況。
第二題(甲班) 70分
class A {
int i1;
int i2;
A () { i1 = 3; i2 = i1+2;}
A (int k) {
i1 = k;
i2= i1+k;
}
}
class B {
Main()
{
A a = new A();
A b = new A(a.i2 + 8);
A c = new A (b.i2 - a.i1);
A d = c;
...
}
}
試繪圖說明當Main()的第四個指令執行完畢時,變數的配置情況。
第二題(乙班) 70分
class A {
int i1;
int i2;
A () { i1 = 3; i2 = 1 - i1;}
A (int k) {
i1 = k;
i2= i1+k;
}
}
class B {
Main()
{
A a = new A();
A b = new A(a.i2 + 8);
A c = new A (b.i2 - a.i2);
A d = c;
...
}
}
試繪圖說明當Main()的第四個指令執行完畢時,變數的配置情況。