Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Multiple choice question for engineering

Set 1

1. Assume the statements S1 and S2 given as:
S1: Given a context free grammar, there exists an algorithm for determining whether L (G) is infinite.
S2: There exists an algorithm to determine whether two context free grammars generate the same language.
Which of the following is true?
a) S1 is correct and S2 is not correct
b) Both S1 and S2 are correct
c) Both S1 and S2 are not correct
d) S1 is not correct and S2 is correct

View Answer

Answer: a [Reason:] The proof of S1 can be seen in various book of theory of computation but s2 is a problem of category undecidable so a contradiction to this assumption can be easily obtained.

2. If P & R are regular and also given that if PQ=R, then
a) Q has to be regular
b) Q cannot be regular
c) Q need not be regular
d) Q has to be a CFL

View Answer

Answer: c [Reason:] If two regular languages when combined do not always produce a regular language.

3. Which of the following conversion is not possible (algorithmically)?
a) Regular grammar to CFG
b) NDFA to DFA
c) NDPDA to DPDA
d) NDTM to DTM

View Answer

Answer: c [Reason:] Not every NDPDA has an equivalent deterministic PDA.

4. Consider the grammar given below E? E+E | E*E | E-E | E/E | E^E | (E) | id Assume that + and ^ have the same but least precedence, * and / have the next higher precedence but the same precedence and finally ^ has the highest precedence. Assume + and ^ associate to the left like * and / and that ^ associates to the right. Choose the correct for the ordered pairs (^,^) , (-,-) , (+,+) , (*,*) in the operator precedence table constructed for the grammar
a) All <
b) All >
c) < > , =
d) < > > >

View Answer

Answer: d [Reason:] This relation is established of basis of the precedence of operators.

5. Recursively enumerable languages are not closed under:
a) Union
b) Intersection
c) Complementation
d) Concatenation

View Answer

Answer: c [Reason:] Recursive languages are closed under the following operations. The Kleene star L * of L the concatenation L * o P of L and P the union L U P the intersection L ∩ P.

6. Grammar that produce more than one Parse tree for same sentence is:
a) Ambiguous
b) Unambiguous
c) Complementation
d) Concatenation Intersection

View Answer

Answer: a [Reason:] an ambiguous grammar is one for which there is more than one parse tree for a single sentence.

7. Automaton accepting the regular expression of any number of a ‘ s is:
a) a*
b) ab*
c) (a/b)*
d) a*b*c

View Answer

Answer: a [Reason:] It gives any number of a’s.

8. Grammars that can be translated to DFAs:
a) Left linear grammar
b) Right linear grammar
c) Generic grammar
d) All of the mentioned

View Answer

Answer: b [Reason:] Right linear grammar can be translated to the DFAs.

9. The language accepted by a Push down Automata:
a) Type0
b) Type1
c) Type2
d) Type3

View Answer

Answer: c [Reason:] A known fact that type 2 grammar is accepted by PDA.

10. Given the following statements: (i) Recursive enumerable sets are closed under complementation. (ii) Recursive sets are closed under complements. Which is/are the correct statements?
a) I only
b) II only
c) Both I and II
d) Neither I nor II

View Answer

Answer: b [Reason:] Recursive languages are closed under the following operations. The Kleene star L * of L the concatenation L * o P of L and P the union L U P the intersection L ∩ P.

Set 2

1. A system program that combines separately compiled modules of a program into a form suitable for execution is
a) Assembler
b) Linking loader
c) Cross compiler
d) None of the mentioned

View Answer

Answer: b [Reason:] The definition of cross compiler.

2. A compiler for a high-level language that runs on one machine and produces code for a different machine is called
a) Optimizing compiler
b) One pass compiler
c) Cross compiler
d) Multipass compiler

View Answer

Answer: c [Reason:] So done by the definition.

3. Cross-compiler is a compiler
a) Which is written in a different language from the source language?
b) That generates object code for the machine it’s running on.
c) Which is written in the same language as the source language?
d) That runs on one machine but produces object code for another machine

View Answer

Answer: a [Reason:] A compiler for a high-level language that runs on one machine and produces code for a different machine is called a cross compiler.

4. Cross compiler is used in Bootstrapping.
a) True
b) False

View Answer

Answer: a [Reason:] Bootstrapping to a new platform. When a software is developed for a new platform, a cross compiler is used to compile necessary tools such as the OS and a native compiler.

5. Is GCC a cross Complier
a) Yes
b) No

View Answer

Answer: a [Reason:] GCC, a free software collection of compilers, also can be used as cross compile. It supports many languages and platforms.

6. The __________ is a technique for building cross compilers for other machines
a) Brazilian Cross
b) Canadian Cross
c) Mexican Cross
d) X-cross

View Answer

Answer: b [Reason:] The Canadian Cross is a technique for building cross compilers for other machines. Given three machines X, Y, and Z, one uses machine X (e.g. running Windows XP on an IA-32 processor) to build a cross compiler that runs on machine Y (e.g. running Mac OS X on an x86-64 processor) to create executables for machine Z.

7. __________ was developed from the beginning as a cross compiler
a) Free Pascal
b) GCC
c) Pascal
d) None of the mentioned

View Answer

Answer: a [Reason:] Free Pascal was developed from the beginning as a cross compiler. The compiler executable (ppcXXX where XXX is target architecture) is capable of producing executables for all OS of the same architecture.

Set 3

1. If we compile the sam.c file with the command “gcc -o sam sam.c”, then the executable file will be
a) a.out
b) sam
c) sam.out
d) None of the mentioned

View Answer

Answer: b [Reason:] This is how the GCC is designed to take names of executable files.

2. What will be output of the following code?

#include<stdio.h>
int main()
{
    printf("%dt",sizeof(6.5));
    printf("%dt",sizeof(90000));
    printf("%d",sizeof('A'));
    return 0;
}

a) 8 4 2
b) 8 4 2
c) 8 4 4
d) 8 4 3

View Answer

Answer: c [Reason:] GCC compilers (32 bit compilers) size of: double is 8 byte long int is 8 byte Character constant is 2 byte.

3. What will be output of the following c code? ( according to GCC compiler)

#include<stdio.h>
int main()
{
    signed x;
    unsigned y;
    x = 10 +- 10u + 10u +- 10;
    y = x;
    if(x==y)
         printf("%d %d",x,y);
    else if(x!=y)
         printf("%u  %u",x,y);
    return 0;
}

a) 0 0
b) 65536 -10
c) 0 65536
d) Compilation error

View Answer

Answer: a [Reason:] Consider on the expression: x = 10 +- 10u + 10u +- 10; 10: It is signed integer constant. 10u: It is unsigned integer constant. X: It is signed integer variable. As we know operators enjoy higher precedence than binary operators. So x = 10 + (-10u) + 10u + (-10); = 10 + -10 + 10 + (-10); = 0 So, Corresponding signed value of unsigned 10u is +10.

4. What will be output of the following c code?

#include<stdio.h>
int main()
{
    const int *p;
    int a=10;
    p=&a;
    printf("%d",*p);
    return 0;
}

a) 0
b) 10
c) Garbage Value
d) Any Memory address

View Answer

Answer: b [Reason:] In the following declaration const int *p; p can keep address of constant integer.

5. What will be output of the following c code?

#include<stdio.h>
int main()
{
    int a= sizeof(signed) +sizeof(unsigned);
    int b=sizeof(const)+sizeof(volatile);
    printf("%d",a+++b);
    return 0;
}

a) 10
b) 9
c) 8
d) Error

View Answer

Answer: c [Reason:] Default data type of signed, unsigned, const and volatile is intSo, a = 4 and b =4 Now, a+++b = a++ + b = 4 + 4 //due to post increment operator. =8 But in Linux gcc compiler size of int is 4 byte so your out will be 16.

6. Which of the following is integral data type?
a) void
b) char
c) float
d) double

View Answer

Answer: b Expanation: In c char is integral data type. It stores the ASCII value .

7. What will be output of the following c code?

#include<stdio.h>
int main()
{
    volatile int a=11;
    printf("%d",a);
    return 0;
}

a) 11
b) Garbage
c) -2
d) Cannot Predict

View Answer

Answer: d [Reason:] Value of volatile variable can’t be predicted because its value can be changed by any microprocessor interrupt.

8. What will be output of the following c code?

#include<stdio.h>
const enum Alpha
{
      X,
      Y=5,
      Z
}p=10;
int main()
{
    enum Alpha a,b;
    a= X;
    b= Z;
    printf("%d",a+b-p); 
    return 0; 
}

a) -4
b) -5
c) 10
d) 11

View Answer

Answer: a [Reason:] Default value X is zero and Z = Y + 1 = 5 + 1 = 6 So, a + b – p =0 + 6 -10 = -4.

Set 4

1. Compiler can diagnose
a) Grammatical errors only
b) Logical errors only
c) Grammatical and logical errors
d) None of the mentioned

View Answer

Answer: a [Reason:] Only syntactical errors can be detected by the compiler.

2. A simple two-pass assembler does which of the following in the first pass.
a) It allocates space for the literals
b) Calculates total length of the program
c) Symbol table is built for the symbols and their value
d) All of the mentioned

View Answer

Answer: d [Reason:] A two-pass assembler. Each pass scans the program, the first pass generates the symbol table and the second pass generates the machine code…

3. A system program that set-up an executable program in main memory ready for execution is
a) Assembler
b) Linker
c) Loader
d) Text editor

View Answer

Answer: c [Reason:] A loader is the part of an operating system that is responsible for loading programs and libraries. It is important that with the starting of a program, as it places programs into memory and executes it.

4. A compiler is a program that
a) Program is put into memory and executes it.
b) Translation of assembly language into machine language.
c) Acceptance of a program written in a high level language and produces an object program.
d) None of the mentioned

View Answer

Answer: c [Reason:] A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).

5. A programmer by mistake writes multiplication instead of division, such error can be detected by a/an
a) Compiler
b) Interpreter
c) Compiler or interpreter test
d) None of the mentioned

View Answer

Answer: d [Reason:] No Logical errors can be detected

6. The computer language generally translated to pseudocode is
a) Assembly
b) Machine
c) Pascal
d) FORTRAN

View Answer

Answer: a [Reason:] An assembly language (or assembler language) is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture’s machine code instructions.

7. A system program that combines separately compiled modules of a program into a form suitable for execution is
a) Assembler
b) Linking Loader
c) Cross Compiler
d) None of the mentioned

View Answer

Answer: b [Reason:] A loader which combines the functions of a relocating loader with the ability to combine a number of program segments that have been independently compiled into an executable program.

8. In which way a macro processor for assembly language can be implemented?
a) Independent two-pass processor
b) Independent one-pass processor
c) Processor put into pass 1 of a standard two pass assembler
d) All of the mentioned

View Answer

Answer: d [Reason:] A general-purpose macro processor or general purpose preprocessor is a macro …designed for string manipulation, macro definition

9. Resolution of externally defined symbols is performed by
a) Linker
b) Loader
c) Compiler
d) Interpreter

View Answer

Answer: a [Reason:] A linker or link editor is a computer program that takes one or more object files generated by a compiler and combines them into a single executable file, library file, or another object file.

10. A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar S—-> xxW ( PRINT “1”) S—-> y { print ” 2 ” } S—-> Sz { print ” 3 ” ) What is the translation of xxxxyzz using the syntax directed translation scheme described by the above rules ?
a) 23131
b) 11233
c) 11231
d) 33211

View Answer

Answer: a [Reason:] Initially 2 is printed then 3 then 1 3 1

Set 5

1. Which of the following is not a regular expression?
a) [(a+b)*-(aa+bb)]*
b) [(0+1)-(0b+a1)*(a+b)]*
c) (01+11+10)*
d) (1+2+0)*(1+2)*

View Answer

Answer: b [Reason:] Except b all are regular expression.

2. Regular expression are
a) Type 0 language
b) Type 1 language
c) Type 2 language
d) Type 3 language

View Answer

Answer: An [Reason:] According to Chomsky hierarchy.

3. Which of the following is true?
a) All subsets of a regular set are always regular
b) All finite subsets of non-regular set are always regular
c) Union of two non regular set of language is not regular
d) Infinite times union of finite set is always regular

View Answer

Answer: b

4. L and ~L are recursive enumerable then L is
a) Regular
b) Context free
c) Context sensitive
d) Recursive

View Answer

Answer: d [Reason:] If L is recursive enumerable and its complement too if and only if L is recursive.

5. Regular expressions are closed under
a) Union
b) Intersection
c) Kleen star
d) All of the mentioned

View Answer

Answer: d [Reason:] According to definition of regular expression.

6. Consider the production of the grammar S->AA A->aa A->bb.Describe the language specified by the production grammar.
a) L = {aaaa,aabb,bbaa,bbbb}
b) L = {abab,abaa,aaab,baaa}
c) L = {aaab,baba,bbaa,bbbb}
d) L = {aaaa,abab,bbaa,aaab}

View Answer

Answer: a [Reason:] The production rules give aaaa or aabb or bbaa or bbbb.

7. Give a production grammar that specified language L = {ai b2i >= 1}:
a) {S->aSbb,S->abb}
b) {S->aSb, S->b}
c) {S->aA,S->b,A->b}
d) None of the mentioned

View Answer

Answer: a [Reason:] S->aSbb, S->abb give a^I a’s and b^2i b’s.