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
-
Myprog.obj
-
Myprog.cls
-
Myprog.class
-
Myprog.exe
C
Correct answer
Explanation
After compilation of the file Myprog.java, byte code is produced. The file name of this byte code is Myprog.class.
-
class abc {
Public static void main(String args[]) {……………}
}
-
class abc {
public Static void main(String args[]) {……………}
}
-
class abc {
Public static void Main(String args[]) {……………}
}
-
class abc {
public static void main(String args[]) {……………}
}
D
Correct answer
Explanation
The correct format for a Java program is as follows:
class abc
{
public static void main(String args[])
{
……………
}
}
Here, the keywords class, public and static must be in lower case. String is the class name.
-
L is necessarily finite.
-
L is regular but not necessarily finite.
-
L is context free but not necessarily regular.
-
L is recursive but not necessarily context free.
A
Correct answer
Explanation
The strings of a language L can be effectively enumerated means a Turing machine exists for language L which will enumerate all valid strings of the language.If the string is in lexicographic order then TM will accept the string and halt in the final state.
But, if the string is not lexicographic order then TM will reject the string and halt in non-final state.Thus, L is recursive language.We can not construct PDA for language L. So, the given language is not context free.
-
? BOF ( ) Prints F
-
? EOF ( ) Prints F
-
? BOF ( ) Prints T
-
? EOF ( ) Prints T
D
Correct answer
Explanation
When the structure of a database file, with 20 records, is modified it will become ? EOF ( ) Prints T
-
$L_1$ $\in P$ and $L_2$ is finite
-
$L_1$ $\in NP$ and $L_2$ $\in P$
-
$L_1$ is undecidable and $L_2$ is decidable
-
$L_1$ is recursively enumerable and $L_2$ is recursive
C
Correct answer
Explanation
We have one to one mapping for all instances of L1 to L2.
L1 is given to be undecidable. Further L1 is polynomial time reducible to L2. (By given mapping). Now if L2 is decidable then there is algorithm to solve L2 in polytime. But then we can solve every instance of L1 in polytime, making L1 also decidable. Contradiction
-
(i), (iii)
-
(ii), (iii)
-
(i), (ii)
-
(i), (ii), (iii)
D
Correct answer
Explanation
The front end performs lexical and syntax analysis (validating statements), semantic analysis (determining content/meaning), and constructs intermediate representation for subsequent phases. All three functions are part of front-end processing.
-
recursive descent parsing
-
shift reduce parsing
-
operator precedence parsing
-
none of the above
A
Correct answer
Explanation
Top-down parsing is also called recursive descent parsing because it recursively expands non-terminals starting from the root. Shift-reduce and operator precedence are bottom-up techniques.
-
right most derivation
-
left most derivation
-
right most derivation in reverse
-
left most derivation in reverse
B
Correct answer
Explanation
Top-down parsers (including predictive parsers) use leftmost derivation - they expand the leftmost non-terminal at each step. Rightmost derivation is used by bottom-up parsers.
-
machine code
-
intermediate code
-
a stream of tokens
-
a parse tree
C
Correct answer
Explanation
The output of lexical analyzer is a stream of tokens.
-
canonical derivation sequence
-
canonical reduction sequence
-
both (1) and (2) above
-
none of the above
B
Correct answer
Explanation
Handle pruning is used in LR parsing to efficiently find the canonical reduction sequence - the unique reverse of rightmost derivation. It helps identify handles without exploring all possibilities.
-
LL
-
<font size="2">C</font>anonical LR
-
SLR
-
LALR
B
Correct answer
Explanation
Canonical LR (CLR) is the most powerful parsing method - it handles all grammars that LR parsing can handle, while SLR, LALR, and LL are progressively more restrictive subsets.
-
LISP
-
COBOL
-
FORTRAN
-
PASCAL
-
SNOBOL
C
Correct answer
Explanation
FORTRAN is considered as the earliest programming language.
-
Compiler
-
Loader
-
Linker
-
Translator
-
Assembler
A
Correct answer
Explanation
A compiler converts a high level language into a language that is understood by a computer.
-
C++
-
Java
-
BPCL
-
None of these
C
Correct answer
Explanation
BPCL refers to Basic Combined Programming Language is the generator of new language called 'C'. Dennis Ritchie implemented this language at Bell laboratories and named it 'C'.
-
Arrays
-
Pointers
-
Structures
-
All of the above
C
Correct answer
Explanation
Structures are user defined data type which are more suitable to use database applications in 'C'.