# 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 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:

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

ISOM3230 Business Applications Programming Methods Common Questions

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

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

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 ???

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 ???

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 ???

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

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()

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()

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

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( )

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