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
D
Correct answer
Explanation
The sort function arranges the elements in alphabetical order, producing ('W', 'X', 'Y'). The unshift operation then adds 'Z' to the beginning of the array, making it the first element at index 0. Therefore, printing $array[0] displays 'Z'.
-
Common Language Runtime
-
Common Language Routine
-
Class Library Routine
-
None
A
Correct answer
Explanation
CLR stands for Common Language Runtime, which is the execution engine of the .NET Framework. It manages memory execution, thread execution, code safety verification, compilation, and other system services, making it a fundamental component of .NET applications.
-
var left-shifted 2 bits
-
var mutliplied by 2 bits
-
var reduced 2 bits
-
None of the above
A
Correct answer
Explanation
The <<= operator in Bash arithmetic evaluation (let) is the left-shift assignment operator. It shifts the bits of var to the left by 2 positions and assigns the result back to var. This is equivalent to multiplying by 4, not 'multiplied by 2 bits' or 'reduced'.
-
ALL , AUTOMATIC , USER
-
AUTO , SYS , LOCAL
-
ALL , LOCAL ,USERDEFINED
-
ALL , AUTO , GLOBAL
A
Correct answer
Explanation
In SAS, the %put statement supports specific keywords to list macro variables in the log. _ALL_ displays all variables, _AUTOMATIC_ displays SAS-defined automatic variables, and _USER_ displays user-defined variables. Other options contain invalid keywords like _AUTO_ or _USERDEFINED_.
-
%'
-
%%'
-
(apostrophe) '
-
(percent) %
A
Correct answer
Explanation
In SAS macro quoting, a percent sign (%) is used inside %str() to escape special characters. The sequence %% escapes the percent sign to yield a literal %, and %' escapes the single quote to yield a literal '. Thus, the resolved value stored in myvar is %'.
-
1
-
0
-
undefined
-
any integer value
-
Referencing a nonexistent macro variable results in a warning message. Referencing an invalid macro variable name results in an error message.
-
Referencing a nonexistent macro variable results in a error message. Referencing an invalid macro variable name results in an warning message.
-
Referencing a nonexistent macro variable and invalid macro variable name results in an error message.
-
Referencing a nonexistent macro variable and invalid macro variable name results in an warning message.
A
Correct answer
Explanation
In SAS, referencing a nonexistent macro variable generates a warning in the log, and the reference is left unresolved. However, referencing an invalid macro variable name (which violates SAS naming rules, such as starting with a number) violates syntax rules and results in a compilation error.
-
It's the same as a constant
-
It's value can be assigned only once
-
You can never assign a value to it
-
You can assign value multiple times
B
Correct answer
Explanation
A readonly field in C# can only be assigned a value during its declaration or within the class's constructor. Once the constructor finishes, its value becomes immutable. This differs from constants, which must be known at compile-time, and regular variables, which can be reassigned multiple times.
-
DLLImport
-
UsingDLL
-
DLLCall
-
CallDLL
A
Correct answer
Explanation
DllImport is the attribute used in C# to call methods from unmanaged code, including COM objects and native DLLs. The syntax is [DllImport("dllname.dll")] for external method declarations. The other options (UsingDLL, DLLCall, CallDLL) are not valid C# keywords or attributes.
-
delegate {TheMethod( int Z) }
-
delegate void TheMethod(int Z) ;
-
delegate: TheMethod (int Z)
-
delegate: {TheMethod (int Z)}
B
Correct answer
Explanation
The correct delegate declaration syntax in C# is 'delegate returnType MethodName(parameters)'. Option B shows this correctly: 'delegate void TheMethod(int Z)'. The other options use incorrect syntax with braces, colons, or missing return types.
-
.NET Framework 2.0 CLR was was introduced with VS 2005
-
.Net Framework 3.0 uses the .NET Framework 2.0 CLR
-
.Net Framework 3.5 uses the .NET Framework 2.0 CLR
-
.Net Framework 3.5 SP1 first time introduce the .NET Framework 3.0 CLR
D
Correct answer
Explanation
.NET Framework versions 2.0, 3.0, and 3.5 all used the same CLR 2.0 runtime. There is no such thing as a '.NET Framework 3.0 CLR' - the runtime versions are CLR 1.x, 2.0, 4.0, and .NET 5+. Statement D falsely claims a 3.0 CLR exists.
B
Correct answer
Explanation
The this keyword in C# refers to the current instance of the class in which it is used, allowing access to its members. Distractors like call and do are keywords reserved for other operations, while that is not a valid C# keyword for referencing the current object.
-
Invoke()
-
StartInvoke()
-
BeginInvoke()
-
SetInvoke()
C
Correct answer
Explanation
BeginInvoke() is the correct method for asynchronous delegate invocation in C#. It initiates the delegate call on a thread pool thread and returns an IAsyncResult object for tracking. Invoke() executes synchronously, while StartInvoke() and SetInvoke() are not standard C# delegate methods.