Option Explicit, Option Inner and Option Strict - Visual Basic Questions and Answers

1.

In Visual Basic, if you keep a variable undeclared, it is automatically taken as___________ data type.

   A.) Object
   B.) Int
   C.) Char
   D.) String

Answer: Option 'A'

Object

Visual basic can create variables “on the fly”. This means that if your code contains undeclared variables, Visual basic creates the variable for you and assigns object data type to it. An undeclared variable is a variable, which does not appear in the declaration statement i.e. the Dim statement.

DigitalOcean Referral Badge

2.

__________ prevents you from using undeclared variable in your code.

   A.) Option Explicit On
   B.) Option Implicit On
   C.) Implicit Off
   D.) Explicit Off

Answer: Option 'A'

Option Explicit On
Because it is so easy to forget to declare a variable, or so easy to misspell a variable’s name while coding, thereby inadvertently creating an undeclared variable, visual Basic provides a way that prevents you from entering undeclared variable in your code. You simply enter Option Explicit On in the General Declaration Section of the code editor window. The statement tells the code editor to alert you if your code contains a name of a undeclared data type.

DigitalOcean Referral Badge

3.

__________ ensures every variable and named constant is declared with a data type.

   A.) Option Infer Off
   B.) Option Infer On
   C.) Option off
   D.) Option On

Answer: Option 'A'

Option Infer Off
When you enter the Option Infer Off statement in the General Declaration Section, the Code Editor ensures that every variable and named constant is declared with a data type. In other words, the statement tells the computer not to infer a memory location’s data type based on the data assigned to the memory location.

DigitalOcean Referral Badge

4.

_________ is used to fit the value of the data type to that of the memory location, implicitly.

   A.) Implicit type conversion
   B.) Convert method
   C.) Conversion function
   D.) Explicit type conversion

Answer: Option 'A'

Implicit type conversion

The data type of the value assigned to a memory location should be same as the memory location itself. If the value’s data type does not match the memory location’s data type, the computer uses a process called implicit type conversion to convert the value to fir its memory location.

DigitalOcean Referral Badge

5.

When a value is converted from one data type to another and can store numbers with greater precision, the value is said to be __________

   A.) Imported
   B.) Exported
   C.) Promoted
   D.) Précised

Answer: Option 'C'

Promoted

When a value is converted from one data type to another data type, which can store either large numbers or numbers with greater precision, the value is said to be promoted. For example, while processing, Dim sales as Double=9, the value 9 will be converted from integer to double as 9.0; thus this value is said to be promoted.

DigitalOcean Referral Badge

6.

When a value is converted from one data type to another and can store numbers with less precision, the value is said to be __________

   A.) Demoted
   B.) Promoted
   C.) Converted
   D.) Exported

Answer: Option 'A'

Demoted

When a value is converted from one data type to another data type, which can store either small numbers, or numbers with less precision, the value is said to be demoted. For example, Dim store as Integer=7.4, the value 7.4 is rounded off that is the decimal part is truncated and stored as 7, that is it is converted from double to integer; thus the value is said to be demoted.

DigitalOcean Referral Badge

7.

You can eliminate the problems of implicit type conversion, with the help of __________

   A.) Explicit On
   B.) Option Strict On
   C.) Implicit Off
   D.) Option Strict Off

Answer: Option 'B'

Option Strict On

Data loss can occur when a value is changed from one data type to narrower data type that is data type with less capacity. We can eliminate such problems of implicit type conversion, with the help of Option Strict On statement in the General Declaration of the Code editor Window. When the Option Strict On appears on the application window, the computer uses the type conversion rules

DigitalOcean Referral Badge

8.

Option Strict On disallows conversion of String data type to __________ implicitly.

   A.) Double
   B.) Object
   C.) Array
   D.) Character

Answer: Option 'A'

Double
Option Strict On disallows conversion of string data type to Double data type. You need to use the Tryparse method to explicitly convert a String to a Double data type.

DigitalOcean Referral Badge

9.

Option Strict On disallows conversion of Double data type to __________ implicitly.

   A.) Double
   B.) Character
   C.) String
   D.) Object

Answer: Option 'C'

String

Option Strict On disallows conversion of double data type to string data type. You need to use the Convert class method to explicitly convert a String to a Double data type.

DigitalOcean Referral Badge

10.

Instead of entering the Option statements in the Code Editor window, you also can enter in the __________

   A.) Properties window
   B.) Project Designer Window
   C.) Project Manager
   D.) File Manager

Answer: Option 'B'

Project Designer Window

Instead of entering the Option statements in the Code editor Window, you can also enter in the Project Designer window or Options dialog box. But it is strongly recommended that you enter the option statement in the code editor window, because doing so ensures that the options are set appropriately; it also makes your code more self-documenting.

DigitalOcean Referral Badge

Option Explicit, Option Inner and Option Strict - Visual Basic Questions and Answers Download Pdf

Recent Posts