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
-
i | j = 3
-
i | j = 2
-
Compile Time Error
-
None
A
Correct answer
Explanation
The bitwise OR operator (|) compares each bit position and returns 1 if either operand has a 1 at that position. Binary 3 is 011 and binary 2 is 010, so 3|2 = 011|010 = 011 = 3.
-
X=10
-
X=0
-
X=16
-
Compile Time Error
C
Correct answer
Explanation
In Java, hexadecimal literals begin with 0x. The value 0x10 in hexadecimal equals decimal 16 (1 × 16^1 + 0 × 16^0 = 16). The prefix indicates number system, not value.
-
i=0
-
i=11
-
Invalid argument to operation
-
None
C
Correct answer
Explanation
Java is case-sensitive. 'Public' must be 'public', and '+++i' is invalid syntax. The pre-increment operator is '++', so '++ + ++i' or '+ + + i' would be required to parse, making this a compilation error.
-
10 & 12
-
10 & 10
-
Compile Time Error
-
None
C
Correct answer
Explanation
Java does not allow chained assignment in declarations like 'int x=y=10'. Each variable must be declared separately, or y must be declared first. The line 'int x=y=10;' is a compile-time error.
-
subs(F,x,,5)
-
subs(f,5,x)
-
subs(5,f,x)
-
subs(f,x,5)
D
Correct answer
Explanation
The subs function syntax is subs(expression, variable, value). For f=3*x^2, subs(f, x, 5) substitutes x=5. Options A has wrong syntax with double comma. Options B and C swap arguments - subs expects (f, variable, value), not (f, value, variable) or (value, f, variable).
-
well-formed
-
well-documented
-
non-validating and validating
-
none of the above
C
Correct answer
Explanation
The claimed answer C (non-validating and validating) is correct. XML parsers are classified into two main types: non-validating parsers (check only for well-formedness) and validating parsers (check both well-formedness and adherence to a DTD or schema). Options A, B, and D are incorrect as they don't represent actual parser classifications.
-
Sashelp.PrdSale
-
Sasuser.MySales
-
Profits.Quarter1
-
all of the above
D
Correct answer
Explanation
All three examples are permanent SAS datasets: Sashelp.PrdSale (library Sashelp), Sasuser.MySales (library Sasuser), and Profits.Quarter1 (library Profits). Permanent libraries persist between sessions, unlike the temporary Work library.
-
proc contents data=area51.all nods;
-
proc contents data=area51 all nods;
-
proc contents data=area51 all noobs;
-
proc contents data=area51 all.nods;
A
Correct answer
Explanation
In SAS, PROC CONTENTS with data=libname.ALL lists all datasets in a library. The NODS option suppresses detailed dataset information. The correct syntax requires a two-level name with the library prefix and an underscore before and after ALL. Option A has the correct spacing and syntax.
D
Correct answer
Explanation
Adobe Dreamweaver was originally developed by Macromedia and is primarily written in C++. Java, C#, and .NET are different programming frameworks/languages not used for the core engine of this desktop application.
B
Correct answer
Explanation
C/C++ is faster than Java, Python, and Pascal because it's compiled to machine code without the overhead of a virtual machine or interpreter. Java uses JVM, Python is interpreted, and Pascal is generally slower than C. C/C++ gives the most direct hardware control.
A
Correct answer
Explanation
In C, integer division truncates toward zero. -5/-4 = 1.25, which truncates to 1 (not -1). The printf with %d displays integer output. This is integer division, not floating-point.
A
Correct answer
Explanation
The while(1); statement is an infinite loop - the semicolon makes it an empty statement that repeats forever. The lines c++ and printf are unreachable code that never executes. The program hangs in the infinite loop, producing no output. This is a classic unreachable code scenario.
-
3.4141
-
3.41426
-
3.414164
-
3.4142
D
Correct answer
Explanation
The format specifier %0.4f means print with 4 decimal places. Standard rounding applies: 3.414164 rounded to 4 places looks at the 5th digit (6), which rounds the 4th digit up from 1 to 2. Therefore 3.4142 is printed. Options A, B, and C are incorrect because they either truncate or round incorrectly.
D
Correct answer
Explanation
The do-while executes once with i=1, printing 1 and incrementing i to 2. The if(i<15) condition is true, so continue jumps back to loop condition. The while(false) condition fails, terminating the loop. Only 1 is printed. The continue statement affects loop control but the false condition guarantees single execution.
-
1212
-
121.2
-
12f(1,2)
-
12f(12)
C
Correct answer
Explanation
The macro f(a,b) uses ## (token pasting) to concatenate 1 and 2 into 12. Macro h(a) calls g(a) which stringifies with #a. So h(f(1,2)) becomes g(12) then f(1,2) as string literal. The first printf outputs f(1,2). The second printf calls g(f(1,2)) directly, which stringifies to 12. Output: f(1,2)12.