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()的第四個指令執行完畢時,變數的配置情況。
2009年9月28日 星期一
2009/09/23 小考
Program
A program is list of instructions written in a programming language that is used to control the behavior of a machine, often a computer.
Function (subroutine)
A portion of code within a larger program, which performs a specific task and is relatively independent of the remaining code.
Assignment
An assignment statement sets or re-sets the value stored in the storage location(s) denoted by a variable nameAn assignment operation modifies the current state of the executing program. Consequently, assignment is dependent on the concept of variables. In an assignment:The expression is evaluated in the current state of the program. The variable is assigned the computed value, replacing the prior value of that variable.
乙班
Statement block
A pair of braces containing zero or more statements.
Expression
An expression in a programming language is a combination of values, variables, operators, and functions that are interpreted (evaluated) according to the particular rules of precedence and of association for a particular programming language, which computes and then produces (returns, in a stateful environment) another value.
Precedence
Order of operationIn an expression with multiple operators, operators with higher precedence execute before operators of lower precedence.