0

programming languages Online Quiz - 56

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

public class Sample{ public static void main(String[] args){ int i=5; if(i==5) throw new ArithmeticException("i is 5"); System.out.println(i); } } Does the code compiles fine?

  1. True

  2. False


Correct Option: B

assertions can force which of the constraints ......

  1. pre conditions

  2. post conditions

  3. exceptions

  4. class invariants


Correct Option: A,B,D

The following will result in which of the following, if the prize is currently "10 Euros" print 'You won $prize';

  1. You won $5.00

  2. You won 5 dollars

  3. You won $prize

  4. You won $5


Correct Option: C

Which of these is NOT a standard output command:

  1. printf

  2. print

  3. type

  4. write


Correct Option: C

The function to a delete file is

  1. untie

  2. delete

  3. unlink

  4. rm


Correct Option: C

Output of the following:s/(\w)/\u$1/g;

  1. Changes all lower case letters in the string stored in the variable $_ to upper case

  2. Changes the first letter in the string stored in the variable $_ to upper case

  3. Changes all letters in the string stored in the most recently used scalar variable to upper case

  4. adds \u in front of every letter or digit in the string in $_


Correct Option: A

AI Explanation

To answer this question, let's understand the given regular expression pattern and its usage in the code:

s/(\w)/\u$1/g;

This regular expression pattern is used to replace every occurrence of a lowercase letter with its uppercase version in a string.

Explanation for each option:

Option A) Changes all lowercase letters in the string stored in the variable $_ to upper case - This option is correct because the given regular expression code will change all lowercase letters to uppercase in the string.

Option B) Changes the first letter in the string stored in the variable $_ to upper case - This option is incorrect because the given regular expression code will change all lowercase letters to uppercase, not just the first letter.

Option C) Changes all letters in the string stored in the most recently used scalar variable to upper case - This option is incorrect because the regular expression code does not refer to a specific variable. It operates on the default variable $_.

Option D) Adds \u in front of every letter or digit in the string in $_ - This option is incorrect because the regular expression code does not add \u in front of every letter or digit. It only changes lowercase letters to uppercase.

Therefore, the correct answer is A) Changes all lowercase letters in the string stored in the variable $_ to upper case.

Which of these is a valid regular expression meaning "contains any digit"?

  1. /[1-9]/

  2. /^\d+$/

  3. /^\d+/

  4. m-\d-


Correct Option: D

open (INPUT,"){ print $_; } How many times will the file get printed?

  1. once

  2. twice

  3. the program will go on into infinite loop

  4. None of the above


Correct Option: A

Which of the following is a valid scalar variable name?

  1. $section_32B

  2. $baby-boy

  3. $401k

  4. $tic#tac#toe


Correct Option: A

Code 1: Code: my @lines = grep /^hi/, @allLines; Code 2: Code: my @lines = (); foreach (@allLines) { push (@lines,$_) if (/^hi/); } What is the difference between the two snippets (Code 1 and Code 2) above?

  1. In code 1, the operation occurs in one command; code 2 iterates each element in the array for matches.

  2. In code 1, the elements of @lines are the indexes in @allLines, in which matches were found.

  3. In code 1, the elements of "@lines" begin with the index in "@allLines", in which the match was found.

  4. In code 1, "@lines" may not necessarily be in the same order; the original lines appear in "@allLines".


Correct Option: C

What type of variable is INPUT?

  1. A File Handle

  2. A List

  3. A Code variable

  4. A Tyleglob


Correct Option: A

For a time in the month of March, the localtime function will return a month of:

  1. 2

  2. 3

  3. Mar

  4. March


Correct Option: A

The following will result in which of the following, if the prize is currently "10 dollars" print 'You won $prize';

  1. You won $10.00

  2. You won 10 dollars

  3. You won $prize

  4. You won $10


Correct Option: C

Which of these is not a method of DateTime object?

  1. AddTick()

  2. GetMonth()

  3. GetHashCode()

  4. AddMilliSeconds()

  5. All the Above


Correct Option: B

Which of these is a value Type?

  1. Arrays

  2. Strings

  3. Enums

  4. None

  5. All the Above


Correct Option: C

In Which of these types do we store the difference between two dates?

  1. String

  2. Type

  3. TimeSpan

  4. int

  5. None


Correct Option: C
  1. Common Language Specification

  2. Common Language Runtime

  3. Base Class Library

  4. None

  5. All the Above


Correct Option: B

Which Class in C# helps to compile a .cs file into .dll file programmatically ?

  1. System.Globalization

  2. System.Diagnostics

  3. CsharpCodeProvider

  4. IcodeCompiler

  5. All the Above


Correct Option: C

MSIL stands for –

  1. Managed Software Intermediate Language

  2. Managed Software InterUsable Language

  3. MicroSoft Intermediate Language

  4. Machine Source Intermediate Language

  5. None


Correct Option: C

How to supress the COPYRIGHT statement issued while compiling a particular .cs file through command line

  1. /noconfig

  2. /nologo

  3. /out

  4. None

  5. All the Above


Correct Option: B
- Hide questions