Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Lab 4

Total questions: 8

Worksheet time: 2mins

Name
Class
Date
1.

What is the correct syntax to define a simple data type in VDM++?

a)

type MyType = seq of char;

b)

type MyType : seq of char;

c)

types MyType = seq of char;

d)

types MyType : seq of char;

2.

Which of the following is an example of defining a union type in VDM++?

a)

Faculty = <FSKTM> | <FEB>;

b)

Faculty = <FSKTM, FEB>;

c)

Faculty : <FSKTM> | <FEB>;

d)

Faculty = {FSKTM, FEB};

3.

Which of the following is NOT a valid predefined type in VDM++?

a)

nat

b)

char

c)

string

d)

real

4.

In VDM++, how do you declare an instance variable of type int within a class?

a)

instance variable studentName : seq of char;

b)

instance variables studentName : seq of char;

c)

instance variable studentName : seq of char = "John Doe";

d)

instance variables studentName = "John Doe";

5.

Which of the following is an example of an explicit function in VDM++?

a)

sum(a, b) == post RESULT = a + b;

b)

sum(a, b) == pre a > 0 and b > 0; post RESULT = a + b;

c)

sum(a, b);

d)

sum(a, b) == a + b;

6.

Which of the following statements about implicit functions is true?

a)

Provide a full implementation of the computation.

b)

Used when you need to sequence operations.

c)

Use pre & post conditions to define expected behavior

d)

Cannot have any conditions.

7.

What is the correct syntax to define an implicit function in VDM++?

a)

multiply(x, y) == post RESULT = x * y;

b)

multiply(x, y) ==> x * y;

c)

multiply(x, y) == x * y;

d)

multiply(x, y) == pre x > 0 and y > 0; post RESULT = x * y;

8.

What is the main difference between a function and an operation in VDM++?

a)

Functions can have pre/postconditions, but operations cannot

b)

Functions change the system state, while operations do not

c)

Operations are used for mathematical calculations only

d)

Operations can change the system state, while functions cannot