Java C Preprocessor Quiz 1 | Java Question and Answers
Finish Quiz
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
Lets take free Java C Preprocessor Quiz 1 | Java Question and Answers. Free Java C Preprocessor Quiz, Online Java, online Test Quiz 1. Java C Preprocessor Quiz 1 Question and Answers 2024. Java online Test Quiz 1. Java C Preprocessor Quiz 1 Free Mock Test 2024. Java C Preprocessor Quiz 1 Question and Answers in PDF. The Java online mock test paper is free for all students. Spring Online is very useful for exam preparation and getting for Rank. Java C Preprocessor Quiz 1 Question and Answers in English. Java C Preprocessor Mock test for topic via C Preprocessor Mode. Here we are providing Java C Preprocessor Quiz in English Now Test your self for “C Preprocessor Online Quiz in English” Exam by using below quiz…
This paper has 20 questions.
Time allowed is 25 minutes.
The Java C Preprocessor Mock Test is Very helpful for all students. Now Scroll down below n click on “Start Quiz” or “Start Test” and Test yourself.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.hCorrect
The preprocessor replaces the line #include <stdio.h> with the system header file of that name. More precisely, the entire text of the file stdio.h replaces the #include directive.
Incorrect
The preprocessor replaces the line #include <stdio.h> with the system header file of that name. More precisely, the entire text of the file stdio.h replaces the #include directive.
-
Question 2 of 20
2. Question
A macro must always be defined in capital letters.
Correct
FALSE, The macro is case insensitive.
Incorrect
FALSE, The macro is case insensitive.
-
Question 3 of 20
3. Question
Macro calls and function calls work exactly similarly.
Correct
False, A macro just replaces each occurrence with the code assigned to it. e.g. SQUARE(3) with ((3)*(3)) in the program.
A function is compiled once and can be called from anywhere that has visibility to the funciton.Incorrect
False, A macro just replaces each occurrence with the code assigned to it. e.g. SQUARE(3) with ((3)*(3)) in the program.
A function is compiled once and can be called from anywhere that has visibility to the funciton. -
Question 4 of 20
4. Question
There exists a way to prevent the same file from getting #included twice in the same program.
Correct
True, We can prevent the same file from getting included again by using a preprocessor directive called #ifndef (short for “if not defined”) to determine whether we have already defined a preprocessor symbol called XSTRING_H. If we have already defined this symbol, the compiler will ignore the rest of the file until it sees a #endif (which in this case is at the end of the file).
#ifndef XSTRING_H
#define XSTRING_H defines the same preprocessor symbol,
Finally, the last line of the file, #endifIncorrect
True, We can prevent the same file from getting included again by using a preprocessor directive called #ifndef (short for “if not defined”) to determine whether we have already defined a preprocessor symbol called XSTRING_H. If we have already defined this symbol, the compiler will ignore the rest of the file until it sees a #endif (which in this case is at the end of the file).
#ifndef XSTRING_H
#define XSTRING_H defines the same preprocessor symbol,
Finally, the last line of the file, #endif -
Question 5 of 20
5. Question
Macros have a local scope.
Correct
False, The scope of macros is globals and functions. Also the scope of macros is only from the point of definition to the end of the file.
Incorrect
False, The scope of macros is globals and functions. Also the scope of macros is only from the point of definition to the end of the file.
-
Question 6 of 20
6. Question
A preprocessor directive is a message from programmer to the preprocessor.
Correct
True, the programmer tells the compiler to include the preprocessor when compiling.
Incorrect
True, the programmer tells the compiler to include the preprocessor when compiling.
-
Question 7 of 20
7. Question
Preprocessor directive #undef can be used only on a macro that has been #define earlier
Correct
True, #undef can be used only on a macro that has been #define earlier
Example: #define PI 3.14
We can undefine PI macro by #undef PIIncorrect
True, #undef can be used only on a macro that has been #define earlier
Example: #define PI 3.14
We can undefine PI macro by #undef PI -
Question 8 of 20
8. Question
Every C program will contain at least one preprocessor directive.
Correct
False, the preprocessor directive is not mandatory in any c program.
Incorrect
False, the preprocessor directive is not mandatory in any c program.
-
Question 9 of 20
9. Question
What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile?
#include<stdio.h>
#define SWAP(a, b, c)(c t; t=a, a=b, b=t)
int main()
{
int x=10, y=20;
SWAP(x, y, int);
printf(“%d %d “, x, y);
return 0;
}Correct
The code would not compile since declaration of t cannot occur within parenthesis.
Incorrect
The code would not compile since declaration of t cannot occur within parenthesis.
-
Question 10 of 20
10. Question
If the file to be included does not exist, the preprocessor flashes an error message.
Correct
True, the included file does not exist it will generate the error.
Incorrect
True, the included file does not exist it will generate the error.
-
Question 11 of 20
11. Question
Macros with arguments are allowed
Correct
True, A macro may have arguments.
Example: #define CUBE(X)(X*X*X)Incorrect
True, A macro may have arguments.
Example: #define CUBE(X)(X*X*X) -
Question 12 of 20
12. Question
Once preprocessing is over and the program is sent for the compilation the macros are removed from the expanded source code.
Correct
True, After preprocessing all the macro in the program are removed.
Incorrect
True, After preprocessing all the macro in the program are removed.
-
Question 13 of 20
13. Question
A preprocessor directive is a message from compiler to a linker.
Correct
FALSE
Example: #define symbol replacement
When the preprocessor encounters #define directive, it replaces any occurrence of symbol in the rest of the code by replacement. This replacement can be an statement or expression or a block or simple text.Incorrect
FALSE
Example: #define symbol replacement
When the preprocessor encounters #define directive, it replaces any occurrence of symbol in the rest of the code by replacement. This replacement can be an statement or expression or a block or simple text. -
Question 14 of 20
14. Question
Will the program compile successfully?
#include<stdio.h>
#define X (4+Y)
#define Y (X+3)int main()
{
printf(“%d “, 4*X+2);
return 0;
}Correct
Reports an error: Undefined symbol X
Incorrect
Reports an error: Undefined symbol X
-
Question 15 of 20
15. Question
Preprocessor directive #ifdef .. #else … #endif is used for conditional compilation.
Correct
True, these macros are used for conditional operation.
#if <constant-expression>
#elif <constant-expression>
#endifIncorrect
True, these macros are used for conditional operation.
#if <constant-expression>
#elif <constant-expression>
#endif -
Question 16 of 20
16. Question
Will the program compile successfully?
#include<stdio.h>
int main()
{
printf(“Java” “Tpoint “);
return 0;
}Correct
Incorrect
-
Question 17 of 20
17. Question
Will the following program print the message infinite number of times?
#include<stdio.h>
#define INFINITELOOP while(1)int main()
{
INFINITELOOP
printf(“JavaTpoint”);
return 0;
}Correct
Yes, the program prints “JavaTpoint” and runs infinitely.
The macro INFINITELOOP while(1) replaces the text INFINITELOOP by while(1)
In the main function, while(1) satisfies the while condition and it prints “JavaTpoint”. Then it comes to while(1) and the loop runs infinitely.
Incorrect
Yes, the program prints “JavaTpoint” and runs infinitely.
The macro INFINITELOOP while(1) replaces the text INFINITELOOP by while(1)
In the main function, while(1) satisfies the while condition and it prints “JavaTpoint”. Then it comes to while(1) and the loop runs infinitely.
-
Question 18 of 20
18. Question
A header file contains macros, structure declaration and function prototypes.
Correct
True, the header file contains classes, function prototypes, structure declaration, macros.
Incorrect
True, the header file contains classes, function prototypes, structure declaration, macros.
-
Question 19 of 20
19. Question
It is necessary that a header files should have a .h extension?
Correct
No, the header files have any kind of extension.
Incorrect
No, the header files have any kind of extension.
-
Question 20 of 20
20. Question
What will be the output of the program?
#include<stdio.h>
#define MAN(x, y) ((x)>(y)) ? (x):(y);int main()
{
int i=10, j=5, k=0;
k = MAN(++i, j++);
printf(“%d, %d, %d “, i, j, k);
return 0;
}Correct
The macro MAN(x, y) ((x)>(y)) ? (x):(y); returns the biggest number of given two numbers.
Step 1: int i=10, j=5, k=0; The variable i, j, k are declared as an integer type and initialized to value 10, 5, 0 respectively.
Step 2: k = MAN(++i, j++); becomes,
=> k = ((++i)>(j++)) ? (++i):(j++);
=> k = ((11)>(5)) ? (12):(6);
=> k = 12
Step 3: printf(“%d, %d, %d “, i, j, k); It prints the variable i, j, k.
In the above macro step 2 the variable i value is increemented by 2 and variable j value is increemented by 1.
Hence the output of the program is 12, 6, 12
Incorrect
The macro MAN(x, y) ((x)>(y)) ? (x):(y); returns the biggest number of given two numbers.
Step 1: int i=10, j=5, k=0; The variable i, j, k are declared as an integer type and initialized to value 10, 5, 0 respectively.
Step 2: k = MAN(++i, j++); becomes,
=> k = ((++i)>(j++)) ? (++i):(j++);
=> k = ((11)>(5)) ? (12):(6);
=> k = 12
Step 3: printf(“%d, %d, %d “, i, j, k); It prints the variable i, j, k.
In the above macro step 2 the variable i value is increemented by 2 and variable j value is increemented by 1.
Hence the output of the program is 12, 6, 12