Computer Knowledge

Programming Languages and Compilers

2,284 Questions

Programming languages and compilers involve the rules, syntax, and semantics used to write and execute software programs. Key areas include scripting languages, object oriented concepts, and parsing algorithms like top down parsers. Practice these computer science questions to build proficiency for technical and computer knowledge exams.

Object oriented languagesScripting languagesCompilers and parsersProgramming syntax

Programming Languages and Compilers Questions

Multiple choice .net
  1. Clear

  2. Copy

  3. Cut

  4. Paste

  5. All of these methods use the clipboard

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To determine which TextBox method does not use the clipboard, we need to understand the purpose of each method and how it interacts with the clipboard.

Let's go through each option and explain if it uses the clipboard or not:

A. Clear: This method does not use the clipboard. It simply clears the contents of the TextBox, removing any text that was previously typed or pasted into it.

B. Copy: This method uses the clipboard. It copies the selected text within the TextBox and places it on the clipboard, allowing it to be pasted elsewhere.

C. Cut: This method uses the clipboard. It cuts the selected text within the TextBox, removing it from the TextBox and placing it on the clipboard for pasting elsewhere.

D. Paste: This method uses the clipboard. It pastes the contents of the clipboard at the current cursor position within the TextBox.

E. All of these methods use the clipboard: This option is incorrect. As explained above, the Clear method does not use the clipboard. Therefore, not all of these methods use the clipboard.

The Answer is: A

Multiple choice .net
  1. in all If...Then statements.

  2. in all Multi-line statements with Else.

  3. in Single Line statements.

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The End If statement is required to close multi-line If blocks, especially when they include an Else clause. Single-line If statements (If condition Then statement) don't require End If. Option B correctly identifies this requirement.

Multiple choice .net
  1. If...Then

  2. Select Case

  3. Do...Loop

  4. For...Next

  5. All of the above.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To solve this question, the user needs to be familiar with the different types of selection structures in programming and their characteristics.

A. If...Then is a type of selection process that uses a single expression to determine which branch to take. This expression can be a Boolean expression, a variable, or a comparison operator. However, If...Then does not involve multiple branches from a single expression.

B. Select Case is a type of selection process that allows multiple branches from a single expression. Depending on the value of the expression, the program will execute the corresponding case statement. This allows for more efficient and organized code when dealing with multiple possible outcomes.

C. Do...Loop is a type of iteration process that allows a block of code to be executed repeatedly until a certain condition is met. It does not involve multiple branches from a single expression.

D. For...Next is a type of iteration process that allows a block of code to be executed for a specific number of times. It does not involve multiple branches from a single expression.

E. All of the above options describe different types of selection and iteration processes in programming, but only option B, Select Case, is an example of a selection process that involves multiple branches from a single expression.

Therefore, the correct answer is: The Answer is B.

Multiple choice .net
  1. Exit Do

  2. Exit For

  3. Exit Form

  4. Exit Select

  5. Exit Sub

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To solve this question, the user needs to be familiar with programming and the concept of exit statements. Exit statements are used to prematurely terminate loops, functions, or procedures in a program.

Now, let's go through each option and explain why it is right or wrong:

A. Exit Do: This option is a valid exit statement in some programming languages, such as Visual Basic. It is used to exit a Do loop.

B. Exit For: This option is a valid exit statement in some programming languages, such as Visual Basic. It is used to exit a For loop.

C. Exit Form: This option is not a valid exit statement. "Form" is typically a term used in graphical user interface (GUI) programming to refer to a window or a user interface element. There is no standard "Exit Form" statement in most programming languages.

D. Exit Select: This option is a valid exit statement in some programming languages, such as Visual Basic. It is used to exit a Select Case or Switch statement.

E. Exit Sub: This option is a valid exit statement in some programming languages, such as Visual Basic. It is used to exit a Subroutine or Function.

Therefore, the correct answer is:

The Answer is: C. Exit Form

Multiple choice .net
  1. Event

  2. Function

  3. Sub

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

To answer this question, the user needs to have some basic knowledge of VB.Net programming language and its concepts.

The answer is E. All of the above.

Explanation:

In VB.Net, there are two types of procedures: Functions and Subs. Both Functions and Subs are used to group a set of statements that perform a specific task.

Functions are procedures that return a value after performing a specific task. Functions are defined using the "Function" keyword.

Subs are procedures that do not return a value after performing a specific task. Subs are defined using the "Sub" keyword.

Events are not procedures, but rather they are actions that occur in response to user actions or system events. Events are used to trigger a specific action or set of actions in an application.

Therefore, option D is incorrect because Events are not a type of procedure in VB.Net. Option E is correct because both Functions and Subs are types of procedures found in VB.Net.

The answer is: E. All of the above.

Multiple choice .net
  1. e

  2. Sender

  3. Receiver

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

An event procedure is a block of code that is executed in response to an event, such as a button click or a form load. When an event is triggered, the event procedure is called and passed certain parameters that provide information about the event.

The parameters that are found in an event procedure may vary depending on the programming language or platform being used, but they generally include the following:

A. e - This parameter represents the event arguments, which provide information about the event that was raised. It may include properties such as the name of the control that raised the event, the type of event, and any additional data associated with the event.

B. Sender - This parameter represents the object that raised the event. It is typically used to identify the control or component that triggered the event.

C. Receiver - This parameter is not commonly found in event procedures, but it may refer to the object or component that is listening for the event.

Therefore, the correct answer is E, all of the above. Both parameter e and Sender are commonly found in event procedures, and in some cases, Receiver may also be present.

Multiple choice .net
  1. End Sub

  2. Handles

  3. Object_Event

  4. Statements

  5. Sub

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

An event procedure is a subroutine that is called in response to an event. The event procedure is defined using the Sub keyword, followed by the name of the event procedure, the Handles keyword, and the name of the event. The event procedure can contain any number of statements.

The End Sub keyword is not optional, as it marks the end of the event procedure. The Handles keyword is also not optional, as it specifies the event that will trigger the event procedure. The Object_Event identifier is optional, and it can be used to specify the object and event that will trigger the event procedure. The Statements are optional, as the event procedure can be empty.

Correct Option: D. Statements

The Statements element is optional in an event procedure. The event procedure can be empty, or it can contain any number of statements. The statements in the event procedure will be executed when the event is triggered.

Here is an example of an event procedure:

Sub btnClick(sender As Object, e As EventArgs)
'This is an event procedure that is triggered when the button is clicked.
'The event procedure contains two statements.

MsgBox("The button was clicked!")
End Sub

As you can see, the event procedure contains two statements. The first statement displays a message box, and the second statement ends the event procedure.

Multiple choice .net
  1. Only arguments of numeric data types are allowed.

  2. A reference to the argument is sent to the procedure.

  3. A copy of the argument is sent to the procedure.

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To understand what happens when a parameter in a procedure is declared ByVal, the user needs to have knowledge of programming concepts and specifically the concept of passing arguments to procedures.

When a parameter is declared ByVal, it means that a copy of the argument is sent to the procedure. This means that any changes made to the parameter inside the procedure will not affect the original argument in the calling code.

Now, let's go through each option and explain why it is right or wrong:

A. Only arguments of numeric data types are allowed: This option is incorrect. When a parameter is declared ByVal, it is not restricted to only numeric data types. It can be used with arguments of any data type.

B. A reference to the argument is sent to the procedure: This option is incorrect. When a parameter is declared ByVal, a reference to the argument is not sent. Instead, a copy of the argument is sent to the procedure.

C. A copy of the argument is sent to the procedure: This option is correct. When a parameter is declared ByVal, a copy of the argument is sent to the procedure. This means that any changes made to the parameter inside the procedure will not affect the original argument in the calling code.

D. Both a and b: This option is incorrect. Option a is incorrect because arguments of any data type are allowed, not just numeric data types. Option b is incorrect because a reference to the argument is not sent when the parameter is declared ByVal.

E. All of the above: This option is incorrect. Option a is incorrect, and option b is incorrect. Only option c is correct.

Therefore, the correct answer is:

The Answer is: C

Multiple choice .net
  1. Parameters

  2. Public

  3. Private

  4. Statements

  5. Sub

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

The correct answer is E. Sub.

The Sub keyword is not an optional element of a sub procedure declaration. It is used to declare the start of a sub procedure. The other elements, such as parameters, public, private, and statements, are optional.

Here is an example of a sub procedure declaration:

Sub MySub()

' This is the body of the sub procedure.

End Sub

As you can see, the Sub keyword is the first element in the declaration. The other elements are optional.

Here is a table that summarizes the optional elements of a sub procedure declaration:

Element Description
Public Indicates that the sub procedure is accessible to all other procedures in all modules.
Private Indicates that the sub procedure is accessible only to other procedures in the module where it is declared.
Parameters A list of variables that are passed to the sub procedure when it is called.
Statements The body of the sub procedure. This is where the code that executes when the sub procedure is called is placed.
Multiple choice .net
  1. Return Sales*0.08

  2. CalculateTax = Sales*0.08

  3. Return CalculateTax (Sales*0.08)

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To send the value generated by a function procedure back to the calling code, you need to use the "return" statement.

Option A) Return Sales*0.08 - This option is correct because it uses the "return" statement to send the value of Sales multiplied by 0.08 back to the calling code.

Option B) CalculateTax = Sales*0.08 - This option is incorrect because it assigns the value of Sales multiplied by 0.08 to the variable CalculateTax, but it does not send the value back to the calling code.

Option C) Return CalculateTax(Sales*0.08) - This option is incorrect because it tries to call the CalculateTax function recursively, which is not necessary and can lead to an infinite loop.

Option D) Both a and b - This option is correct because it includes both the correct options A and B.

Option E) All of the above - This option is incorrect because option C is incorrect.

Therefore, the correct answer is D) Both a and b.

Multiple choice .net
  1. 1

  2. 2

  3. 3

  4. Any number of variables can be declared in an array.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To solve this question, the user needs to know about variables and data structures.

A variable is a named storage location in a computer's memory that holds a value. In programming, variables are used to store and manipulate data.

A structured data type is a data type that groups together related values. Examples of structured data types include arrays, structs, and classes.

Now let's go through each option and explain why it is right or wrong:

A. 1: This option is incorrect. Variables are not limited to just one in a structured data type. Structured data types allow for the grouping of multiple variables together.

B. 2: This option is incorrect. Structured data types can have more than two variables. The number of variables allowed in a structured data type is not limited to any specific number.

C. 3: This option is incorrect for the same reason as option B. The number of variables allowed in a structured data type can be more than three.

D. Any number of variables can be declared in an array: This option is partially correct. Arrays are a type of structured data type that allows for the declaration of any number of variables. Arrays can hold multiple values of the same data type.

Therefore, the correct answer is:

D. Any number of variables can be declared in an array.

Multiple choice .net
  1. A.

  2. shift.

  3. control.

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The KeyPress event fires when a character key (like 'A') is pressed. Modifier keys like Shift, Control, and Alt trigger KeyDown/KeyUp events but not KeyPress because they don't produce character input. KeyPress specifically captures printable characters.

Multiple choice .net
  1. Close

  2. Peak

  3. Flush

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To solve this question, the user needs to have a basic understanding of the StreamReader and StreamWriter classes in .NET.

Option A: Close - This method is found in both the StreamReader and StreamWriter classes. It is used to close the underlying stream and free up any resources associated with it.

Option B: Peek - This method is not found in both the StreamReader and StreamWriter classes. It is only found in the StreamReader class and is used to return the next available character without reading it from the underlying stream.

Option C: Flush - This method is found in both the StreamReader and StreamWriter classes. It is used to flush the buffer and write any remaining data to the underlying stream.

Option D: Both A and B - This option is incorrect because option B is not found in both the StreamReader and StreamWriter classes.

Option E: All of the above - This option is incorrect because option B is not found in both the StreamReader and StreamWriter classes.

Therefore, the correct answer is:

The Answer is: A. Close.

Multiple choice .net
  1. IO

  2. Stream

  3. StreamIO

  4. Both a and b.

  5. All of the above.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Both StreamReader and StreamWriter inherit from the abstract Stream class, which is the base class for all input/output streams in .NET. IO is a namespace, not a class. StreamIO isn't a standard .NET class. The Stream class provides fundamental read/write methods that these classes extend.