15
S.2 C.L. Half-yearly Examination (2012-13) 1 Hong Kong Taoist Association Tang Hin Memorial Secondary School 2012-2013 Half-yearly Examination S.2 Computer Literacy Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. 9:30 a.m. (1 hour) Instructions: 1. Full mark of this paper is 100. 2. This Question-Answer Book consists of 15 pages. 3. Attempt ALL questions. 4. Answer in complete sentences whenever applicable, or your effective communication marks will be deducted. Name Class Class Number Marks 12-13 S.2 C.L. Question- Answer Book

S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 1

Hong Kong Taoist Association Tang Hin Memorial Secondary School

2012-2013 Half-yearly Examination

S.2

Computer Literacy

Question-Answer Book

Date: 3 January 2012

Time: 8:30 a.m. – 9:30 a.m. (1 hour)

Instructions:

1. Full mark of this paper is 100.

2. This Question-Answer Book consists of 15 pages.

3. Attempt ALL questions.

4. Answer in complete sentences whenever applicable, or your effective communication marks will be

deducted.

Name

Class

Class Number

Marks

12-13

S.2 C.L.

Question-

Answer

Book

Page 2: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 2

Section A: Multiple Choice Questions (2M@, Total 30 marks)

Put a “” in the box of the most suitable answer.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

A

B

C

D

Which of the following is a reserved keyword in Visual Basic? 1.

A. Visual

B. Basic

C. Project

D. Class

Which of the following can be the name of a variable in Visual Basic? 2.

I. studentHeight

II. P&G

III. 123Times

A. I Only

B. I, II Only

C. II, III Only

D. I, II and III

Which of the following is NOT a valid operator? 3.

A. +

B. +=

C. Mod

D. +−

Which of the following is NOT a property of a form? 4.

A. Left

B. Number

C. Text

D. BackColor

Page 3: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 3

Which of the following data types can be used to record the marks of a student in HKTA Tang 5.

Hin Memorial Secondary School?

A. Integer

B. Double

C. Boolean

D. Variable

Which of the following can be the value of a Boolean variable in Visual Basic? 6.

A. Yes

B. No

C. True

D. Never

Which of the following statements contains an error? 7.

A. Label1.Text = Label2.Text + Label3.Text

B. TextBox1.Left = 300

C. Me.Title = "234567"

D. Button987.Enabled = False

The type of user interface with buttons, text boxes and labels is called 8.

A. GUI.

B. CLI.

C. prompt.

D. SLI.

In Visual Basic, which operator is processed last? 9.

A. *

B. ^

C. /

D. \

If you double click a button in the design view, the handler of which event is created? 10.

A. Click

B. TextChanged

C. DoubleClick

D. Load

Page 4: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 4

Evaluate the VB expression “3 + 18 Mod 12 \ 5” 11.

A. 1

B. 3

C. 4

D. 4.2

Which of the following statement will generate the dialog box below? 12.

A. MsgBox("Hello!" & vbCrLf & "I'm Stephanie.")

B. MsgBox(Hello! & vbCrLf & I'm Stephanie.)

C. MsgBox("Hello!" & vbCrLf & vbCrLf & "I'm Stephanie.")

D. MsgBox(Hello! & vbCrLf & vbCrLf & I'm Stephanie.)

Study the following program, 13.

Public Class Form1

Private Sub Form1_Load(...) Handles MyBase.Load

Dim x As Double = Val(InputBox("Enter x:"))

Dim y As Double

y = Math.Sqrt(x * x + 6)

MsgBox(y)

End Sub

End Class

If the user enters “2.5” into the InputBox, what will be the output?

A. 2.5

B. 3.5

C. 4.5

D. 5.5

Page 5: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 5

In the following program, the text box at the left is TextBox1, and the other is TextBox2. 14.

Public Class Form1

Private Sub Button1_Click(...) Handles Button1.Click

Dim a As Integer

Dim b As Integer

a = TextBox1.Text

b = TextBox2.Text

b = a * 2

a = b + 3

Label1.Text = a + b

End Sub

End Class

When the user clicks “Button1”, the text in Label1 is changed to…

A. 6

B. 9

C. 12

D. 15

TextBox1 TextBox2

Page 6: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 6

Which of the code below will make the following change if we click Button1? 15.

A. Public Class Form1

Private Sub Button1_Click(...) Handles Me.Click

TextBox2.AppendText(TextBox1.Text)

End Sub

End Class

B. Public Class Form1

Private Sub Button1_Click(...) Handles Me.Click

TextBox2.Text = TextBox1.Text

End Sub

End Class

C. Public Class Form1

Private Sub Button1_Click(...) Handles Button1.Click

TextBox2.AppendText(TextBox1.Text)

End Sub

End Class

D. Public Class Form1

Private Sub Button1_Click(...) Handles Button1.Click

TextBox2.Text = TextBox1.Text

End Sub

End Class

TextBox1

TextBox2

Page 7: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 7

Section B: VB expressions (2M@, Total 10 marks)

Convert the Mathematical expressions below to Visual Basic expressions.

Mathematical Expression VB Expression

e.g 𝑎 = 𝑏 + 𝑐 a = b + c

1. v = 𝑢 + 𝑎𝑡

2. 𝐴 =1

2(𝑎 + 𝑏)ℎ

3. 𝑚 =𝑦2 − 𝑦1

𝑥2 − 𝑥1

(𝑥1, 𝑥2, 𝑦1, 𝑦2 are

names of variables.)

4. 𝑎 = −𝑤2𝑥

5. 𝑦 = (𝑎 + 𝑏)3

Section C: Coding (2M per line, Total 14 marks)

Write the V.B. statement for the following operation for each case.

Case Operation V.B. Statement(s)

e.g. The text in Button1 changes to “I’m

clicked!”

Button1.Text = "I'm clicked!"

1. Title of the Form1 (as the current working

form) becomes “Hello!”.

2. The Button2 can be seen but cannot be

clicked.

3. The background colour of the Label3

becomes orange.

4. The TextBox4 cannot be seen.

5. The running programme stops running.

6. The Form5 appears while Form1

disappears. (Form1 is the startup and the

current working form) (2 lines)

Page 8: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 8

Section D: Programming (Total 15 marks)

1. Study the changes of this programme, fill in the blanks of the programme codes. [1M@, 5M]

Step 1

When Form1 is loaded, the user is asked to enter his/her name, of which is represented by the

variable “inName”.

Step 2

As the user Jay enters his name, another interface like this appears.

Line Programme code

1 Private Sub Form1_Load(…) Handles (1)____________________

2 Dim inName As (2)____________________

3 inName = (3)_______________ ("(4)____________________ ")

4 MsgBox("(5)________________________________________ ")

5 End Sub

Page 9: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 9

2. Study the changes of this programme, fill in the blanks of the programme codes. [1M@, 2M]

Design View Step 1 Step 2

This is the design view of a

form, with 4 labels, 2 textboxes

and 1 button. All properties

settings remain as the default

values.

Then, Form1 appears with the

Button1 (“Check”) unable to be

clicked.

Button1 becomes clickable

when the content in the

TextBox2 is modified.

Line Programme code

1 Private Sub TextBox2_TextChanged(…) Handles TextBox2.TextChanged

2 (1)____________________ = (2)____________________

3 End Sub

TextBox1

TextBox2

Button1

Page 10: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 10

3. Study the changes of this programme, fill in the blanks of the programme codes. [1M@, 8M]

Design view Step 1 Step 2

This is the design view of a

form. The AutoSize property of

Label3 is set as False.

The user enters the class and

class number into the two

textboxes, e.g. 2E, 49.

As Button1 is clicked, Label3

reveals the information as

shown, and the values in

TextBox1 and TextBox2

disappear.

Step 3 Step 4

The user enters another set of

values.

Label3 reveals another set of

responses.

TextBox1

TextBox2

Page 11: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 11

Line Programme code

1 Private Sub Button1_Click(…) Handles Button1.Click

2 Dim inClass As (1)____________________ = TextBox1.Text

3 Dim inNumber As Integer = (2)__________ (TextBox2.Text)

4 Dim CheckDigit As (3)____________________

5 Dim inText As String = (4)____________________

6 CheckDigit = inNumber (5)____________________

7 Label3.Text = "(6)____________________"

& CheckDigit & "." & (7)__________________

& "If your Check Digit is 1, you are in odd number group."

8 TextBox1.Text = (8)____________________

9 TextBox2.Text = inText

10 End Sub

Page 12: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 12

Section E: Debugging (Total 11 marks)

Study this programme:

Design view of the

Form1 with

Button1 as the

“Check out!”

button.

Step 1

As the programme

is loaded, user can

enter the amount of

fillet-O-fish and

color s/he wants to

buy.

Step 2

As the user clicks

the “Check out!”

button, the amount

to be paid is shown

in another

interface, with the

Form1 changed

like this.

Step 3

As the user clicks

the “確定” button,

the Form1

disappears.

Step 4

The last interface

appears, and after

clicking the “確

定” button on this

interface, the

programme stops.

Form1 disappear!

Background

Colour : Red

Page 13: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 13

Based on the flow shown above, the programme is as below, with 11 mistakes, and 1 mistake at

each problem line.

Line Programme code

e.g. Private Sub Button1(…) Handles Button1

1 Dim numFillet Is Integer = Val(TextBox1.Text)

2 Let numCola be Integer = Val(TextBox2.Text)

3 Dim total As String

4 total = numFillet 14.8 + numCola 10.4

5 Me.BackColor = ChangeTo.Red

6 Button1.Seen = False

7 MsgBox("Total: $" = total)

8 Me.Hidden()

9 MsgBox(Thank you for your purchase.)

10 Stop

11 Sub End

Find out ALL of them and REWRITE the WHOLE programme line for each line. [1M@, 11M]

Line Correct Version

e.g. Private Sub Button1_Click(…) Handles Button1.Click

1

2

3

4

5

6

7

8

9

10

11

Page 14: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 14

Section F: Comprehension (Total 20 marks)

Figure 1

Figure 2

(a) Refer to the Figure 1 and Figure 2, what is the value in TextBox4 when the user enters 3600

into TextBox1 and 3800 into TextBox2 and then clicks “Convert”? (1 mark)

(b) Refer to the Figure 1 and Figure 2, if the statement “TextBox4.Text = sec1 + sec2” is changed

to “TextBox4.Text = Val(sec1) + Val(sec2)”, what is the value in TextBox4 if the user enters

3600 into TextBox1 and 3800 into TextBox2 and then clicks “Convert”? (1 mark)

(c) Refer to the following program segment.

h = i \ 3600

m = (i Mod 3600) \ 60

s = i Mod 3600 Mod 60

(i) What are the meanings of “\” and “Mod” operators? (2 marks)

(ii) Find the value of h, m and s if i = 7400. (6 marks)

h is

m is

s is

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button1.Click

Dim sec, sec1, sec2 As String

sec1 = TextBox1.Text

sec2 = TextBox2.Text

TextBox4.Text = sec1 + sec2

End Sub

End Class

TextBox1

TextBox2

TextBox4

Button1

Page 15: S.2 Computer Literacy Question-Answer Booklwc1/files/files/s2_cl/1213_s2cp_hf.pdf · Question-Answer Book Date: 3 January 2012 Time: 8:30 a.m. – 9:30 a.m. (1 hour) Instructions:

S.2 C.L. Half-yearly Examination (2012-13) 15

(d) The program segment of part (c) is inserted into the program as shown below.

Figure 3

Figure 4

(i) If the user enters 7399.9 into TextBox1 and 0.1 into TextBox2.

I. What is the value of i. (1 mark)

II. What are the values of TextBox3 and TextBox4 after the “Convert” button is

clicked. (3 marks)

(ii) If the user clicks the “Convert” button without any input, write down what you see in

“Form 1” on Figure 3. (3 marks)

(iii) If the user now enters 0.1 into TextBox1 and 7399.9 into TextBox2 and then click

“Convert”, will the values of TextBox3 and TextBox4 be the same as the result in

part (d) (i)? If not, state their new values. (3 marks)

* * * End of Paper * * *

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button1.Click

Dim sec, sec1, sec2 As String

Dim i, m, h, s As Integer

sec1 = TextBox1.Text

sec2 = TextBox2.Text

sec = Val(sec1) + Val(sec2)

i = Val(sec)

h = i \ 3600

m = (i Mod 3600) \ 60

s = i Mod 3600 Mod 60

TextBox3.Text = h & "hours" & m & "minutes" & s & "seconds"

TextBox4.Text = sec1 + sec2

End Sub

End Class

TextBox1

TextBox2

TextBox4

Button1

TextBox3