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
-
programming languages
-
register counter
-
location counter
-
instruction counter
A
Correct answer
Explanation
Macro languages allow programmers to define shorthand for sequences of instructions, which are then expanded by a macro processor. This system provides a way to extend a base language, making it a specialized form of programming language. Unlike counters, which track addresses or values, macro languages focus on code abstraction and generation.
-
imperative
-
declarative
-
assembler directive
-
all of these
-
system parsing
-
programming parsing
-
bottom up parsing
-
none of these
C
Correct answer
Explanation
In compiler theory, parsing is the process of determining the grammatical structure of a sequence of tokens. The two primary strategies for this are top-down parsing, which builds the parse tree from the root down to the leaves, and bottom-up parsing, which starts from the leaves and works up to the root. These two methods cover the vast majority of parsing algorithms used in computer science.
-
storage allocation
-
lexical analysis
-
semantic analysis
-
none of these
A
Correct answer
Explanation
A compiler is divided into analysis and synthesis phases. The synthesis phase is responsible for taking the analyzed source code and producing the target machine code, which involves storage allocation for variables and the actual generation of instructions. Lexical and semantic analysis are part of the analysis phase, which occurs before synthesis.
-
to convert high level language into machine level language.
-
to convert high level language into assembly language
-
to convert assembly language into machine level language
-
all of these
A
Correct answer
Explanation
The primary definition of a compiler is a program that translates high-level language (HLL) source code into machine-level language (object code). While some compilers may output assembly language as an intermediate step, the ultimate task that distinguishes a compiler from an assembler is the conversion from a high-level abstraction to a machine-executable format. Option C describes an assembler, not a compiler.
-
Array
-
GET
-
$_GET[]
-
$_ENV[]
-
$_SERVER[]
C
Correct answer
Explanation
It represents an array that includes all the GET variables that PHP received from the client browser.
-
_destructor()
-
Set accessor
-
setCookies()
-
isset()
-
unset()
D
Correct answer
Explanation
This method determines whether a certain variable has been declared already by PHP.
-
HTML
-
C++
-
C
-
Java applet
-
PHP5
E
Correct answer
Explanation
This programming language supports dereferencing objects that are returned from methods.
-
It provides the format specific to the strings.
-
It is used to denote an object.
-
It specifies the new value should be sent -retain on assignment and the old value sent release.
-
It specifies the new value should be sent -copy on assignment and the old value sent release.
-
It returns the class and memory address of the object.
A
Correct answer
Explanation
NSLog() uses format specifiers to indicate substitution tokens, just like the C standard library printf() function.
-
Its is used to retain the assigned value and release the previously set value.
-
It makes the compiler NOT check what other threads are executing over the value at the same time.
-
It is used to create automatically the setter and the getter methods for the property.
-
The “retain” property is needed when the attribute is a pointer to an object.
-
Both 1 and 4
E
Correct answer
Explanation
These are correct statements about 'retain' attribute in Objective C property.
-
The NULL pointer can not be accessible by memory address.
-
A NULL pointer does not have any memory pointer.
-
int main ()
{
int *ptr = NULL;NSLog(@"The value of ptr is : %xn", ptr );
return 0;
}
is the correct syntax for NULL pointer.
-
The NULL pointer is a constant with a value of zero defined in several standard libraries.
-
None of the above
E
Correct answer
Explanation
All are correct statements about NULL pointer n Objective C.
-
The dealloc method is called on an object when it is being removed from memory.
-
This method is called automatically by the runtime.
-
The dealloc method is not called on objects, if garbage collection is enabled.
-
The [super dealloc] is used to ask the superclass to do its cleanup. If one does not do this, the object will not be removed.
-
This method is used to set initial values for the instance variables.
E
Correct answer
Explanation
This is true about initial method, dealloc() is used to delete the memory objects.
-
It is used to iterate through a collection.
-
It can throw an exception in case the collection is mutated.
-
It allows returning a pointer to internal storage.
-
Fast Enumeration supports using NSEnumerator objects.
-
All of the above
-
BASIC
-
FORTRAN
-
C
-
None of these
C
Correct answer
Explanation
Unix was famously rewritten in the C programming language in 1973, which made it highly portable compared to earlier operating systems written in assembly.
-
Replicator
-
Compiler
-
Converter
-
Operator
B
Correct answer
Explanation
A compiler is a specialized program that translates source code written in a high-level programming language into machine-readable code (machine language).