Presentation is loading. Please wait.

Presentation is loading. Please wait.

Midterm 26 March 2015 (4:30-5:30 pm) – Rm5620 Closed book exam MC Questions only x25 Up to L(7) Methods Scope: video lectures (+Lab), forum discussions,

Similar presentations


Presentation on theme: "Midterm 26 March 2015 (4:30-5:30 pm) – Rm5620 Closed book exam MC Questions only x25 Up to L(7) Methods Scope: video lectures (+Lab), forum discussions,"— Presentation transcript:

1 Midterm 26 March 2015 (4:30-5:30 pm) – Rm5620 Closed book exam MC Questions only x25 Up to L(7) Methods Scope: video lectures (+Lab), forum discussions, lecture reviews and in-class exercises Cheat Sheet (already given TODAY. Will NOT provide on 26 March.) Typical questions: Output, Error, Syntax, Logic, Flow etc. Remark: Time, Cheat Sheet+Pencil+Eraser+Stud ID ONLY, Explicit and Strict options

2 ISOM3230 Business Applications Programming Methods Common Questions

3 Return Value Return Value Caller subroutine Caller subroutine Program Flow Program Flow Data Type Data Type Option Strict Option Strict

4 Return Value Q 1:What is the return value? Q 1:What is the return value? Public Function MCQ() As String MCQ = "A" MCQ = "A" MCQ = "B" MCQ = "B" Return "C" Return "C" Return "D" Return "D" End Function

5 Return Value Q :What is the return value? Q :What is the return value? Public Function MCQ() As String MCQ = "A" MCQ = "A" MCQ = "B" MCQ = "B" End Function The return value is ???

6 Return Value Q :What is the return value? Q :What is the return value? Public Function MCQ() As String Return "C" Return "C" Return "D" Return "D" End Function The return value is ???

7 Return Value Q :What is the return value? Q :What is the return value? Public Function MCQ() As String MCQ = "A" MCQ = "A" MCQ = "B" MCQ = "B" Return "C" Return "C" Return "D" Return "D" End Function The return value is ???

8 Caller subroutine Q2: Write a subroutine to call MCQ() Public Function MCQ() As String MCQ = "A" MCQ = "A" MCQ = "B" MCQ = "B" Return "C" Return "C" Return "D" Return "D" End Function Public Sub Caller Public Sub Caller End Sub Answer = MCQ() Dim Answer As String

9 Caller subroutine (Student) Q: Write a subroutine to call MCQ() Public Function MCQ() As String MCQ = "A" MCQ = "A" MCQ = "B" MCQ = "B" Return "C" Return "C" Return "D" Return "D" End Function Public Sub Caller Public Sub Caller End Sub caller = MCQ() Dim caller As String MCQ()

10 Caller subroutine (Shorter=Better) Q: Write a subroutine to call MCQ() Public Function MCQ() As String MCQ = "A" MCQ = "A" MCQ = "B" MCQ = "B" Return "C" Return "C" Return "D" Return "D" End Function Public Sub Caller Public Sub Caller End Sub Dim Answer As String = MCQ()

11 Program Flow Q3: Which method is going to be executed first? Public Sub Sub1() Dim i As Integer = 0 Dim i As Integer = 0 Do While i <= 8 Do While i <= 8 i += 4 i += 4 If i 6 Then Sub2() If i 6 Then Sub2() If i <= 7 Then Sub3() If i <= 7 Then Sub3() Loop Loop End Sub Public Sub Sub2() Debug.Print("IS") Debug.Print("IS") End Sub Public Sub Sub3() Debug.Print("3230") Debug.Print("3230") End Sub Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ ByVal e As System.EventArgs) _ Handles MyBase.Load Handles MyBase.Load Sub1() Sub1() End Sub RAM i 04 "IS" "3230" 8 "IS" 12 "IS" IS 3230 IS

12 Data Type Option Strict ON Public Class Form1 Public Function MyFun() As _____(a)_________ Dim s As String = "0." Dim s As String = "0." For i As Integer = 3 To 1 Step -1 For i As Integer = 3 To 1 Step -1 s &= i s &= i Next Next Return CInt(s) Return CInt(s) End Function Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ ByVal e As System.EventArgs) _ Handles MyBase.Load Handles MyBase.Load MessageBox.Show( _______(b)__________) MessageBox.Show( _______(b)__________) End Sub End Class Q4: Fill in the blanks. integer MyFun() MyFun() CStr( )

13 Strict Option Option Strict ON Public Class Form1 Public Function MyFun1() As Double Return 2.2 Return 2.2 End Function Public Function MyFun2() As Double Dim i as Integer = 1 Return i Return i End Function End Class Strict ON disallows implicit narrowing conversions E.g., Integer -> Double OK Double -> Integer NOT OK Error


Download ppt "Midterm 26 March 2015 (4:30-5:30 pm) – Rm5620 Closed book exam MC Questions only x25 Up to L(7) Methods Scope: video lectures (+Lab), forum discussions,"

Similar presentations


Ads by Google