C#, Perl, and Java Programming Fundamentals

Test your knowledge across multiple programming languages including C#/.NET concepts, Perl syntax and file operations, and Java exception handling.

20 Questions Published

Questions

Question 1 True/False

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
Question 2 Multiple Choice (Multiple Answers)

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

  1. pre conditions
  2. post conditions
  3. exceptions
  4. class invariants
Question 3 Multiple Choice (Single Answer)

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
Question 4 Multiple Choice (Single Answer)

Which of these is NOT a standard output command:

  1. printf
  2. print
  3. type
  4. write
Question 5 Multiple Choice (Single Answer)

The function to a delete file is

  1. untie
  2. delete
  3. unlink
  4. rm
Question 6 Multiple Choice (Single Answer)

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 $_
Question 7 Multiple Choice (Single Answer)

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

  1. /[1-9]/
  2. /^\d+$/
  3. /^\d+/
  4. m-\d-
Question 8 Multiple Choice (Single Answer)

open (INPUT,"<inpput.txt"); while(){ 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
Question 9 Multiple Choice (Single Answer)

Which of the following is a valid scalar variable name?

  1. $section_32B
  2. $baby-boy
  3. $401k
  4. $tic#tac#toe
Question 10 Multiple Choice (Single Answer)

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".
Question 11 Multiple Choice (Single Answer)

What type of variable is INPUT?

  1. A File Handle
  2. A List
  3. A Code variable
  4. A Tyleglob
Question 12 Multiple Choice (Single Answer)

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

  1. 2
  2. 3
  3. Mar
  4. March
Question 13 Multiple Choice (Single Answer)

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
Question 14 Multiple Choice (Single Answer)

Which of these is not a method of DateTime object?

  1. AddTick()
  2. GetMonth()
  3. GetHashCode()
  4. AddMilliSeconds()
  5. All the Above
Question 15 Multiple Choice (Single Answer)

Which of these is a value Type?

  1. Arrays
  2. Strings
  3. Enums
  4. None
  5. All the Above
Question 16 Multiple Choice (Single Answer)

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

  1. String
  2. Type
  3. TimeSpan
  4. int
  5. None
Question 17 Multiple Choice (Single Answer)

CTS is contained in –

  1. Common Language Specification
  2. Common Language Runtime
  3. Base Class Library
  4. None
  5. All the Above
Question 18 Multiple Choice (Single Answer)

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
Question 19 Multiple Choice (Single Answer)

MSIL stands for –

  1. Managed Software Intermediate Language
  2. Managed Software InterUsable Language
  3. MicroSoft Intermediate Language
  4. Machine Source Intermediate Language
  5. None
Question 20 Multiple Choice (Single Answer)

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