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 technology programming languages
  1. +VE GREATER THAN -VE

  2. +VE LESS THAN -VE

  3. Compile error

  4. Edited Numeric field cannot be used for comparison.

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

The code will produce a compilation error. The PIC clauses PIC +9(2).99 and PIC -9(2).99 are invalid COBOL syntax. In COBOL, to define signed numeric fields, you use 'S' as a separate sign clause prefix (e.g., PIC S9(2).99), not + or - symbols embedded in the PIC clause. The + and - symbols are used in editing (output formatting), not in data definition clauses.

Multiple choice technology programming languages
  1. mmmmaaaannnn

  2. aaaammmmnnnn

  3. aaaannnnmmmm

  4. Compilation Error

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

The loop iterates 3 times (for 'm','a','n'). In each iteration, four expressions print the same character: s[i](array indexing), *(s+i) (pointer dereference), *(i+s) (pointer arithmetic with reversed order), and i[s](array indexing with swapped indices). This is valid C syntax. Each character prints 4 times sequentially: mmmm aaa nnnn.

Multiple choice technology programming languages
  1. 1 2 3 4 5

  2. 5 4 3 2 1

  3. compilation error

  4. None

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

The variable 'var' is static, meaning it retains its value between recursive calls of main(). In each call, printf prints 'var' before it is decremented post-evaluation (post-decrement). If 'var' is non-zero after decrement, main() is called again. The sequence printed is 5, 4, 3, 2, 1, stopping when 'var' becomes 0.

Multiple choice technology programming languages
  1. 3 4 6 5 2 2 2 2 2 2

  2. 4 6 5 2 2 2 2 2 2 3

  3. 2 2 2 3 4 6 5 2 2 2

  4. 2 2 2 2 2 2 3 4 6 5

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

The array c is initialized with float values that are truncated to integers: {2, 3, 4, 6, 5}. The first loop prints *c (which is c[0], i.e., 2) five times, outputting ' 2 2 2 2 2 '. The second loop prints the dereferenced pointer p (which starts at c and increments), outputting the individual elements ' 2 3 4 6 5 ' sequentially. Combined, this outputs ' 2 2 2 2 2 2 3 4 6 5 '.

Multiple choice technology programming languages
  1. 1 3 1 0 0

  2. 0 1 0 1 3

  3. 0 0 3 1 1

  4. 0 0 1 3 1

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

The expression evaluates left-to-right with short-circuit: i++&&j++&&k++||l++. First, i++ uses -1 (false), so i becomes 0 and the entire AND chain short-circuits (j++, k++ don't execute). Since -1 is false, the OR evaluates l++, making l=3. m = (-1) || 3 = 1. Final: i=0, j=-1, k=0, l=3, m=1.

Multiple choice technology programming languages
  1. I Know C

  2. I Don't Know C

  3. Compilation error

  4. None

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

When comparing float (1.1) with double (1.1), precision differs. float 1.1 is stored as 1.10000002384185791016, double 1.1 is 1.10000000000000008882. They are NOT equal. Thus the else branch executes, printing 'I Know C'. This demonstrates floating-point precision differences between types.

Multiple choice technology web technology
  1. Dot Net Charting Control

  2. MS Charts

  3. Silver Light Rich Graphs

  4. Excel in built chart

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

MS Charts (Microsoft Chart Controls) is the standard charting component provided by Microsoft for .NET applications. It offers a comprehensive set of chart types and visualization features for displaying data graphically. Dot Net Charting Control is a third-party alternative, Silver Light Rich Graphs are for Silverlight applications, and Excel's built-in charts are for Excel-specific solutions.

Multiple choice technology web technology
  1. Yes

  2. No

  3. Both

  4. None of these

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

In web forms, the Page Load event fires before control events like button clicks or selection changes. The page lifecycle processes Page Load first (where initial data binding and setup occur), then processes postback events triggered by user interactions. This sequence is important because event handlers often rely on data or state set during Page Load.

Multiple choice technology programming languages
  1. perl -c <<programname>>

  2. perl -c

  3. You cannot compile a program

  4. perl -e <<programname>>

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

The -c flag in Perl performs a syntax check (compile) without actually executing the program. This is useful for catching errors before running code. Option B (-c without filename) is incomplete, and option D (-e) executes inline code, not compilation.

Multiple choice technology programming languages
  1. sub test;

  2. sub test {};

  3. sub test[];

  4. none of the above

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

Forward declarations in Perl use the syntax "sub subroutine_name;" - the semicolon without a body indicates this is a declaration, not a definition. Option B with {} is a full definition with an empty body, and option C with [] is invalid syntax.

Multiple choice technology programming languages
  1. delete

  2. unlink

  3. rename

  4. deletefile

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

unlink is the Perl function for deleting files - it removes the link between a filename and the file's data. "delete" (option A) is for removing hash elements, rename (option C) moves files, and deletefile doesn't exist as a built-in.

Multiple choice technology programming languages
  1. VALUE OF WS-COUNT: 0

  2. VALUE OF WS-COUNT: 1

  3. Compile error

  4. None of the above

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

The variable WS-COUNT is set to zero. The conditional statement checks if WS-COUNT equals 0, which is true, executing the CONTINUE statement. Afterward, the ADD +1 TO WS-COUNT statement increments WS-COUNT to 1. Displaying the variable thus outputs the value 1.

Multiple choice technology programming languages
  1. VALUE OF WS-COUNT: 0

  2. VALUE OF WS-COUNT: 1

  3. Compile error

  4. None of the above

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

WS-COUNT starts at ZERO (0). The IF condition is true, so NEXT SENTENCE executes. In COBOL, NEXT SENTENCE skips to the next statement after the next period (sentence terminator). Since END-IF is not a period, and the ADD statement comes after END-IF in the same sentence, NEXT SENTENCE within the IF would skip over both the IF body AND the ADD statement until it finds the next period. Thus WS-COUNT remains 0.

Multiple choice technology web 2.0
  1. xmlhttp=new XMLHttpRequest();

  2. xmlhttp=new XMLHttpRequest("Microsoft.XMLHTTP");

  3. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  4. IE5 and IE6 do not support XMLHttpRequest

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

In Internet Explorer 5 and 6, the XMLHttpRequest object was implemented as an ActiveX control rather than a native JavaScript object. The correct syntax is xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"). Modern browsers use new XMLHttpRequest(), but this doesn't work in IE5/IE6.