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
-
+VE GREATER THAN -VE
-
+VE LESS THAN -VE
-
Compile error
-
Edited Numeric field cannot be used for comparison.
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.
-
mmmmaaaannnn
-
aaaammmmnnnn
-
aaaannnnmmmm
-
Compilation Error
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.
-
1 2 3 4 5
-
5 4 3 2 1
-
compilation error
-
None
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.
-
3 4 6 5 2 2 2 2 2 2
-
4 6 5 2 2 2 2 2 2 3
-
2 2 2 3 4 6 5 2 2 2
-
2 2 2 2 2 2 3 4 6 5
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 '.
-
1 3 1 0 0
-
0 1 0 1 3
-
0 0 3 1 1
-
0 0 1 3 1
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.
-
I Know C
-
I Don't Know C
-
Compilation error
-
None
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.
C
Correct answer
Explanation
The current architecture is based on .NET Framework 3.5, which was released in 2007 and introduced features like Language Integrated Query (LINQ), extension methods, and AJAX support for web applications. This framework version was widely adopted for enterprise applications in the late 2000s.
-
Dot Net Charting Control
-
MS Charts
-
Silver Light Rich Graphs
-
Excel in built chart
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.
-
Yes
-
No
-
Both
-
None of these
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.
-
perl -c <<programname>>
-
perl -c
-
You cannot compile a program
-
perl -e <<programname>>
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.
-
sub test;
-
sub test {};
-
sub test[];
-
none of the above
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.
-
delete
-
unlink
-
rename
-
deletefile
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.
-
VALUE OF WS-COUNT: 0
-
VALUE OF WS-COUNT: 1
-
Compile error
-
None of the above
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.
-
VALUE OF WS-COUNT: 0
-
VALUE OF WS-COUNT: 1
-
Compile error
-
None of the above
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.
-
xmlhttp=new XMLHttpRequest();
-
xmlhttp=new XMLHttpRequest("Microsoft.XMLHTTP");
-
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
-
IE5 and IE6 do not support XMLHttpRequest
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.