0

programming languages Online Quiz - 171

Description: programming languages Online Quiz - 171
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Batch file commands are not case sensitive.

  1. True

  2. False


Correct Option: A

which of this command is used for starting a window application thru batch files?

  1. type

  2. open

  3. start

  4. go


Correct Option: C

Which of this command is used for prompting the user to press any key to continue in batch files?

  1. prompt

  2. pause

  3. ask

  4. enter


Correct Option: B

which of this command is used to run another batch file within a batch file?

  1. continue

  2. goto

  3. route

  4. call


Correct Option: D

which of this is used to prevent any of the commands in the batch file from being displayed?

  1. @

  2. #

  3. $

  4. %


Correct Option: A

Variables in the interface must be initialized and are static & final.

  1. True

  2. False


Correct Option: A
  1. The program has a syntax error.

  2. The program has a runtime error.

  3. The program runs fine, but displays nothing.

  4. The program runs fine and displays It is even!.


Correct Option: D

Analyze the following program fragment: int x; double d = 1.5; switch (d) { case 1.0: x = 1; case 1.5: x = 2; case 2.0: x = 3; }

  1. The program has a syntax error because the required break statement is missing in the switch statement.

  2. The program has a syntax error because the required default case is missing in the switch statement

  3. The switch control variable cannot be double.

  4. No errors


Correct Option: C

AI Explanation

To analyze the given program fragment, let's go through each option:

Option A) The program has a syntax error because the required break statement is missing in the switch statement. This option is incorrect because the absence of a break statement is not a syntax error. However, it can lead to unexpected behavior in the program, such as falling through to the next case.

Option B) The program has a syntax error because the required default case is missing in the switch statement. This option is incorrect because the absence of a default case is not a syntax error. A default case is optional and is executed when none of the cases match the switch control variable.

Option C) The switch control variable cannot be double. This option is correct. In C, the switch control variable can only be an integer type (char, int, long, enum). It cannot be a floating-point type like double. Therefore, this program fragment would result in a compilation error.

Option D) No errors. This option is incorrect because, as mentioned earlier, the program fragment would result in a compilation error due to using a double as the switch control variable.

Therefore, the correct answer is C) The switch control variable cannot be double.

Analyze the following code. public class Test { public static void main(String[] args) { System.out.println(max(1, 2)); } public static double max(int num1, double num2) { System.out.println("max(int, double) is invoked"); if (num1 > num2) return num1; else return num2; } public static double max(double num1, int num2) { System.out.println("max(double, int) is invoked"); if (num1 > num2) return num1; else return num2; } }

  1. The program cannot compile because you cannot have the print statement in a non-void method

  2. The program cannot compile because the compiler cannot determine which max method should be invoked

  3. The program runs and prints 2 followed by "max(int, double)" is invoked.

  4. The program runs and prints 2 followed by "max(double, int)" is invoked.


Correct Option: B

What is sum after the following loop terminates? int sum = 0; int item = 0; do { item++; sum += item; if (sum > 4) break; } while (item < 5);

  1. 5

  2. 6

  3. 7

  4. 8


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) 5 - This option is incorrect because the loop will continue until the value of item is 5, and the sum at that point will be 6.

Option B) 6 - This option is correct. Let's break down the loop execution:

  • Initially, sum is 0 and item is 0.
  • In the first iteration, item is incremented to 1, and sum is updated to 1.
  • In the second iteration, item is incremented to 2, and sum is updated to 3 (1 + 2).
  • In the third iteration, item is incremented to 3, and sum is updated to 6 (3 + 3).
  • Since sum is now greater than 4, the loop terminates.

Option C) 7 - This option is incorrect because the loop terminates when the sum is greater than 4, which happens at sum = 6 as explained above.

Option D) 8 - This option is incorrect because the loop terminates when the sum is greater than 4, which happens at sum = 6 as explained above.

The correct answer is B) 6. This option is correct because the loop terminates when the sum is greater than 4, and at that point, the sum is 6.

Which of the following abbreviations is incorrectly expanded?

  1. CTS - Common Type System

  2. CLS - Common Language Specification

  3. CAS - Component Authorization Specification

  4. FCL - Framework Class Library


Correct Option: C
Explanation:

To solve this question, the user needs to know the expansion of the given abbreviations and cross-check if they are correct.

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

A. CTS - Common Type System: This expansion is correct. The Common Type System (CTS) is a component of the .NET framework that defines a set of rules that all .NET languages must follow.

B. CLS - Common Language Specification: This expansion is correct. The Common Language Specification (CLS) is a set of rules that defines a subset of the .NET framework that can be used by all .NET languages.

C. CAS - Component Authorization Specification: This expansion is incorrect. The correct expansion of CAS is Code Access Security. It is a feature of the .NET framework that provides security by restricting the code's access to resources and operations.

D. FCL - Framework Class Library: This expansion is correct. The Framework Class Library (FCL) is a collection of reusable classes, interfaces, and value types that are included in the .NET Framework.

Therefore, the answer is:

The Answer is: C. CAS - Component Authorization Specification

Which of the following statements is false about Windows Communication Framework (WCF)

  1. WCF Service can define Data, Service, fault and Message contract

  2. MSMQ binding, Web Service (WS) binding, Basic binding and TCP binding are part of standard binding supported by WCF

  3. WCF also support authentication using Issued token by secure token service

  4. WCG support Message reliability without ordered delivery


Correct Option: D

Which of the following features was first introduced with .Net 2.0

  1. .Net Compact Framework

  2. Support for IP6

  3. Windows Card Space

  4. Generics


Correct Option: D

Windows Presentation Foundation - the new user interface system was introduced with

  1. .NET Framework 1.1

  2. .NET Framework 2.0

  3. .NET Framework 3.0

  4. .NET Framework 3.5


Correct Option: C

Which of the following statements is false about Common Language Runtime

  1. .NET Framework 2.0 CLR was was introduced with VS 2005

  2. .Net Framework 3.0 uses the .NET Framework 2.0 CLR

  3. .Net Framework 3.5 uses the .NET Framework 2.0 CLR

  4. .Net Framework 3.5 SP1 first time introduce the .NET Framework 3.0 CLR


Correct Option: D

What attribute must be set on a validator control for the validation to work ?

  1. Validate

  2. ValidateControl

  3. ControlToBind

  4. ControlToValidate


Correct Option: D

AI Explanation

To answer this question, you need to understand the purpose of a validator control in web development.

A validator control is used to validate user input on a web form. It checks whether the input matches certain criteria, such as a required field, a specific format, or a range of values. In order for the validation to work correctly, you need to specify the control that should be validated.

The correct attribute that must be set on a validator control for the validation to work is:

D) ControlToValidate

The ControlToValidate attribute is used to specify the ID of the control that needs to be validated. This attribute tells the validator control which input field to check for validation.

Option A) Validate - This option is incorrect because there is no attribute called "Validate" associated with a validator control. Option B) ValidateControl - This option is incorrect because there is no attribute called "ValidateControl" associated with a validator control. Option C) ControlToBind - This option is incorrect because there is no attribute called "ControlToBind" associated with a validator control.

Therefore, the correct answer is D) ControlToValidate. This attribute needs to be set on a validator control to specify the control that needs to be validated.

How to protect view state from tampering when it's passed over an unencrypted channel ?

  1. In Page directive set EnableViewStateMac="true"

  2. In Register directive set EnableViewStateMac="true"

  3. In web config set Protectviewstate="true"

  4. In IIS set Viewstate protection.


Correct Option: A

AI Explanation

To protect the view state from tampering when it's passed over an unencrypted channel, you can enable the ViewStateMac (Message Authentication Code) by setting the EnableViewStateMac attribute to "true" in the Page directive.

Let's go through each option to understand why it is correct or incorrect:

Option A) In Page directive set EnableViewStateMac="true" - This option is correct because enabling the ViewStateMac adds a MAC to the view state, which ensures its integrity and prevents tampering. The MAC is checked on the server-side when the view state is received, and if it doesn't match, an exception is thrown.

Option B) In Register directive set EnableViewStateMac="true" - This option is incorrect because the Register directive is not used for enabling the ViewStateMac. It is used for registering custom server controls on the page.

Option C) In web config set Protectviewstate="true" - This option is incorrect because the Protectviewstate attribute in the web.config file is used to enable or disable view state encryption, not MAC protection. Enabling view state encryption ensures that the view state data is encrypted before being sent to the client.

Option D) In IIS set ViewState protection - This option is incorrect because there is no specific ViewState protection setting in IIS. ViewState protection is implemented at the application level, usually within the application code or configuration.

The correct answer is A) In Page directive set EnableViewStateMac="true". This option is correct because enabling the ViewStateMac in the Page directive adds a MAC to the view state, ensuring its integrity and preventing tampering.

What does ASP stand for ?

  1. All Standard Pages

  2. Active Server Pages

  3. A Server Page

  4. Active Standard Pages


Correct Option: B
- Hide questions