Important Linux GCC Compiler Objective Questions
Q – 1 The correct sequence of GCC compilation process is:
a) preprocessing -> compilation -> assemble -> linking
b) assemble -> preprocessing -> compilation -> linking
c) preprocessing -> assemble -> compilation -> linking
d) none of the mentioned
Ans- a) preprocessing -> compilation -> assemble -> linking
Q – 2 What is the role of linker in the compilation process?
a) linker links the object code with the library code
b) linker converts machine code into executable machine code
c) linker generates an executable file
d) all of the mentioned
Ans- d) all of the mentioned
Q – 3 The compiler converts:
a) assembly code into machine code
b) preprocessed source code into assembly code
c) machine code into assembly code
d) none of the mentioned
Ans- b) preprocessed source code into assembly code
Q – 4 The a.out file is in the:
a) ELF format
b) EXE format
c) both (a) and (b)
d) none of the mentioned
Ans- a) ELF format
Q – 5 The preprocessor creates the file with extension:
a) .a
b) .i
c) .s
d) .o
Ans- b) .i
Q – 6 The macros specifies in source code are expanded by:
a) pre-processor
b) assembler
c) compiler
d) linker
Ans- a) preprocessor
Q – 7 If we do not specify the executable file name at the compilation time in GCC, then in linux the compiler creates executable named as:
a) a.out
b) a.exe
c) x.out
d) x.exe
Ans- a) a.out
Q – 8 The object file contains the:
a) assembly code
b) machine code
c) modified source code
d) none of the mentioned
Ans- b) machine code
Q – 9 If google.c is compiled with GCC, then the google.s file will contain the:
a) assembly code
b) machine code
c) preprocessed code
d) expanded source code
Ans- a) assembly code
Q – 10 The assembly code is converted into the machine code by:
a) compiler
b) assembler
c) linker
d) none of the mentioned
Ans- b) assembler
Q – 11 The preprocessor removes the _______ from the source code.
a) comments
b) header files
c) both (a) and (b)
d) none of the mentioned
Ans- a) comments
Q – 12 Which one of the following command can be used to provide executable permissions for a file?
a) chmod +x
b) chmod 777
c) both (a) and (b)
d) none of the mentioned
Ans- c) both (a) and (b)
Q – 13 Command line parameters are passed by the:
a) preprocessor
b) assembler
c) compiler
d) linker
Ans- d) linker
Q – 14 Which compilation step makes sure that all the undefined symbols in the code are resolved?
a) linking
b) compiling
c) preporcessing
d) none of the mentioned
Ans- a) linking
Q – 15 Which one of the following is not true?
a) we need to manually go through all intermediate stages to generate an executable in gcc
b) gcc compilation process always contains 4 stages
c) both (a) and (b)
d) none of the mentioned
Ans- a) we need to manually go through all intermediate stages to generate an executable in gcc
Q – 16 The COFF stands for:
a) common object file format
b) combined operation for file formats
c) combined object file format
d) none of the mentioned
Ans- a) common object file format
Q – 17 The lines in our code that begin with the “#” character are:
a) pre-processor directives
b) macros
c) header files
d) none of the mentioned
Ans- a) preprocessor directives
Q – 18 In the pre-processing stage of compilation:
a) header files are actually expanded and included in the source code of the program
b) macros are replaced by their respective values
c) all the comments are stripped off
d) all of the mentioned
Ans- d) all of the mentioned
Q – 19 Preprocessed files are given the file extension _____ for c++ programs.
a) .i
b) .ii
c) .iii
d) none of the mentioned
Ans- b) .ii
Q – 20 Which gcc option turns off certain features of gcc that are incompatible with ISO C89?
a) -ansi
b) -ISO
c) -ver
d) none of the mentioned
Ans- a) -ansi
Q – 21 The command “gcc -S google.c” will:
a) stop compilation process after the generation of assembly code file
b) generate google.s file
c) both (a) and (b)
d) none of the mentioned
Ans- c) both (a) and (b)
Q – 22 The assembly code generated depends upon the:
a) processor architecture
b) RAM size
c) both (a) and (b)
d) none of the mentioned
Ans- c) both (a) and (b)
Q – 23 Which option of gcc inhibit all warning messages?
a) -w
b) -x
c) -y
d) -z
Ans- a) -w
Q – 24 Which gcc option stops compilation process after preprocessing stage?
a) -e
b) -f
c) -E
d) -F
Ans- c) -E
Q – 25 Pipes are used rather than temporary files for communication between the various stages of compilation in gcc when:
a) -pipe option is used
b) -temp option is used
c) -disable -temp option is used
d) none of the mentioned
Ans- a) -pipe option is used
Q – 26 The option -fsyntax-only of gcc:
a) checks the code for syntax error
b) checks the code for fatal error
c) both (a) and (b)
d) none of the mentioned
Ans- a) checks the code for syntax error
Q – 27 The -v option of gcc:
a) print the commands executed to run the stages of compilation
b) version of the gcc compiler
c) both (a) and (b)
d) none of the mentioned
Ans- a) print the commands executed to run the stages of compilation
Q – 28 If we compile the google.c file with the command “gcc -c google.c”, then the output file will be:
a) google.o
b) google.s
c) google.i
d) none of the mentioned
Ans- a) google.o
Q – 29 If we compile the google.c file with the command “gcc -o google google.c”, then the executable file will be:
a) a.out
b) google
c) google.out
d) none of the mentioned
Ans- b) google
Q – 30 Which gcc option includes debugging info in the generated object code?
a) -g
b) -c
c) -p
d) none of the mentioned
Ans- a) -g
Q – 31 Which one of the following command creates the executable file a.out?
a) gcc -o google.c
b) gcc google.c
c) gcc -o a.out
d) gcc a.out
Ans- b) gcc google.c
Q – 32 The command “cpp google.c > google.i” will:
a) create the expanded source code file google.i for the source code file google.c
b) append the content of the google.c into google.i
c) give an error
d) none of the mentioned
Ans- a) create the expanded source code file google.i for the source code file google.c
Q – 33 Which option of gcc makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes?
a) -p
b) -P
c) -q
d) -Q
Ans- d) -Q
Q – 34 The -Wextra option of gcc:
a) is same as -w option
b) does not exist
c) enables extra warning messages
d) none of the mentioned
Ans- c) enables extra warning messages
Q – 35 Which gcc option undefined a pre-processor macro?
a) -U
b) -u
c) -undefine
d) none of the mentioned
Ans- a) -U
Q – 36 Which gcc option reports the cpu time taken by each sub-process in the compilation sequence?
a) -time
b) -cpu
c) -process
d) none of the mentioned
Ans- a) -time
Q – 37 Which one of the following is not true?
a) source codes can not be compiled with static libraries in gcc
b) -O is used for optimization in gcc
c) both (a) and (b)
d) none of the mentioned
Ans- a) source codes can not be compiled with static libraries in gcc
Q – 38 The command “gcc -save-temps google.c” will generate:
a) google.i
b) google.s
c) google.o
d) all of the mentioned
Ans- d) all of the mentioned
Q – 39 The gcc option -Wunused warns when a _____ variable is unused aside from its declaration.
a) variable
b) function
c) macro
d) none of the mentioned
Ans- a) variable
Q – 40 The command line options of gcc can also be read from a file with:
a) @
b) $
c) #
d) none of the mentioned
Ans- c) #
Q – 41 Which option of the gcc is used to warn is padding is included in structure?
a) -Wpadded
b) -Wpad
c) -Wpadding
d) none of the mentioned
Ans- a) -Wpadded
Q – 42 What is the job of -Werror option in gcc?
a) it avoids all the errors present in the source code
b) it makes all warnings into errors
c) it stores all the errors of source code into a seperate file
d) none of the mentioned
Ans- b) it makes all warnings into errors
Q – 43 The -fPIC option of gcc:
a) generates the position independent code of shared libraries
b) opens the source file in readonly mode
c) both (a) and (b)
d) none of the mentioned
Ans- a) generates the position independent code of shared libraries
Q – 44 The -H option of gcc:
a) prints the name of each header file used
b) is used to include header file
c) ignores the header file which are not required by source code
d) none of the mentioned
Ans- a) prints the name of each header file used
Q – 45 The -shared option of gcc generates shared ______ for shared library.
a) object file
b) preprocessed file
c) source file
d) none of the mentioned
Ans- a) object file
Q – 46 The command “as -o google.o google.s” will:
a) generate object file google.o
b) provide an error if google.s exists
c) both (a) and (b)
d) none of the mentioned
Ans- a) generate object file google.o
Q – 47 Which option of gcc adds include directory of header files?
a) -i
b) -I
c) -e
d) -E
Ans- b) -I
Q – 48 Which option of gcc enables compiler’s all warning messages?
a) -Wall
b) -War
c) -Warn
d) none of the mentioned
Ans- a) -Wall
Q – 49 Which option of gcc links with a library file?
a) -l
b) -L
c) -link
d) none of the mentioned
Ans- a) -l
Q – 50 Which option of gcc looks in the provided directory for library files?
a) -l
b) -L
c) -link
d) none of the mentioned
Ans- b) -L