Java C Functions Test 1 - Java C Functions 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 play with our Java C Functions Test 1 – Java C Functions Question and Answers. Free Java C Functions Quiz, Java C Functions Quiz 1 Question and Answers 2024. Java online Test Quiz 1. Java C Functions Quiz 1 Free Mock Test 2024. Java C Functions 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 Functions Quiz 1 Question and Answers in English. Java C Functions Mock test for topic via C Functions Mode. Here we are providing Java C Functions Quiz in English Now Test your self for “C Functions Online Quiz in English” Exam by using below quiz…
This paper has 20 questions.
Time allowed is 25 minutes.
The Java C Functions 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
The keyword used to transfer control from a function back to the calling function is
Correct
The keyword return is used to transfer control from a function back to the calling function.
Example:#include
int add(int, int); /* Function prototype */int main()
{
int a = 4, b = 3, c;
c = add(a, b);
printf(“c = %d “, c);
return 0;
}
int add(int a, int b)
{
/* returns the value and control back to main() function */
return (a+b);
}
Output:
c = 7Incorrect
The keyword return is used to transfer control from a function back to the calling function.
Example:#include
int add(int, int); /* Function prototype */int main()
{
int a = 4, b = 3, c;
c = add(a, b);
printf(“c = %d “, c);
return 0;
}
int add(int a, int b)
{
/* returns the value and control back to main() function */
return (a+b);
}
Output:
c = 7 -
Question 2 of 20
2. Question
What is the notation for following functions?
1. int f(int a, float b)
{
/* Some code */
}2. int f(a, b)
int a; float b;
{
/* Some code */
}Correct
KR Notation means Kernighan and Ritche Notation.
Incorrect
KR Notation means Kernighan and Ritche Notation.
-
Question 3 of 20
3. Question
Functions can be called either by value or reference
Correct
True, A function can be called either call by value or call by reference.
Example:
Call by value means c = sub(a, b); here value of a and b are passed.
Call by reference means c = sub(&a, &b); here address of a and b are passed.Incorrect
True, A function can be called either call by value or call by reference.
Example:
Call by value means c = sub(a, b); here value of a and b are passed.
Call by reference means c = sub(&a, &b); here address of a and b are passed. -
Question 4 of 20
4. Question
How many times the program will print “JavaTpoint” ?
#include<stdio.h>
int main()
{
printf(“JavaTpoint”);
main();
return 0;
}Correct
A call stack or function stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing.
A stack overflow occurs when too much memory is used on the call stack.
Here function main() is called repeatedly and its return address is stored in the stack. After stack memory is full. It shows stack overflow error.
Incorrect
A call stack or function stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing.
A stack overflow occurs when too much memory is used on the call stack.
Here function main() is called repeatedly and its return address is stored in the stack. After stack memory is full. It shows stack overflow error.
-
Question 5 of 20
5. Question
If return type for a function is not specified, it defaults to int
Correct
Incorrect
-
Question 6 of 20
6. Question
Functions cannot return more than one value at a time
Correct
True, A function cannot return more than one value at a time. because after returning a value the control is given back to calling function.
Incorrect
True, A function cannot return more than one value at a time. because after returning a value the control is given back to calling function.
-
Question 7 of 20
7. Question
A function may have any number of return statements each returning different values.
Correct
True, A function may have any number of return statements each returning different values and each return statements will not occur successively.
Incorrect
True, A function may have any number of return statements each returning different values and each return statements will not occur successively.
-
Question 8 of 20
8. Question
A function cannot be defined inside another function
Correct
A function cannot be defined inside the another function, but a function can be called inside a another function.
Incorrect
A function cannot be defined inside the another function, but a function can be called inside a another function.
-
Question 9 of 20
9. Question
In C all functions except main() can be called recursively.
Correct
Any function including main() can be called recursively.
Incorrect
Any function including main() can be called recursively.
-
Question 10 of 20
10. Question
Names of functions in two different files linked together must be unique
Correct
True, If two function are declared in a same name, it gives “Error: Multiple declaration of function_name())”.
Incorrect
True, If two function are declared in a same name, it gives “Error: Multiple declaration of function_name())”.
-
Question 11 of 20
11. Question
If a function contains two return statements successively, the compiler will generate warnings. Yes/No ?
Correct
Yes. If a function contains two return statements successively, the compiler will generate “Unreachable code” warnings.
Example:
#include<stdio.h>
int mul(int, int); /* Function prototype */int main()
{
int a = 4, b = 3, c;
c = mul(a, b);
printf(“c = %d “, c);
return 0;
}
int mul(int a, int b)
{
return (a * b);
return (a – b); /* Warning: Unreachable code */
}
Output:
c = 12Incorrect
Yes. If a function contains two return statements successively, the compiler will generate “Unreachable code” warnings.
Example:
#include<stdio.h>
int mul(int, int); /* Function prototype */int main()
{
int a = 4, b = 3, c;
c = mul(a, b);
printf(“c = %d “, c);
return 0;
}
int mul(int a, int b)
{
return (a * b);
return (a – b); /* Warning: Unreachable code */
}
Output:
c = 12 -
Question 12 of 20
12. Question
Every function must return a value
Correct
No, If a function return type is declared as void it cannot return any value.
Incorrect
No, If a function return type is declared as void it cannot return any value.
-
Question 13 of 20
13. Question
Is it true that too many recursive calls may result into stack overflow?
Correct
Yes, too many recursive calls may result into stack overflow. because when a function is called its return address is stored in stack.
After sometime the stack memory will be filled completely. Hence stack overflow error will occur.
Incorrect
Yes, too many recursive calls may result into stack overflow. because when a function is called its return address is stored in stack.
After sometime the stack memory will be filled completely. Hence stack overflow error will occur.
-
Question 14 of 20
14. Question
Will the following functions work?
int f1(int a, int b)
{
return ( f2(20) );
}
int f2(int a)
{
return (a*a);
}Correct
Yes, It will return the value 20*20 = 400
Example:
#include <stdio.h>
int f1(int, int); /* Function prototype */
int f2(int); /* Function prototype */int main()
{
int a = 2, b = 3, c;
c = f1(a, b);
printf(“c = %d “, c);
return 0;
}int f1(int a, int b)
{
return ( f2(20) );
}int f2(int a)
{
return (a * a);
}
Output:
c = 400Incorrect
Yes, It will return the value 20*20 = 400
Example:
#include <stdio.h>
int f1(int, int); /* Function prototype */
int f2(int); /* Function prototype */int main()
{
int a = 2, b = 3, c;
c = f1(a, b);
printf(“c = %d “, c);
return 0;
}int f1(int a, int b)
{
return ( f2(20) );
}int f2(int a)
{
return (a * a);
}
Output:
c = 400 -
Question 15 of 20
15. Question
In a function two return statements should never occur.
Correct
No, In a function two return statements can occur but not successively.
Example:
#include <stdio.h>
int mul(int, int); /* Function prototype */int main()
{
int a = 0, b = 3, c;
c = mul(a, b);
printf(“c = %d “, c);
return 0;
}/* Two return statements in the mul() function */
int mul(int a, int b)
{
if(a == 0 || b == 0)
{
return 0;
}
else
{
return (a * b);
}
}
Output:
c = 0Incorrect
No, In a function two return statements can occur but not successively.
Example:
#include <stdio.h>
int mul(int, int); /* Function prototype */int main()
{
int a = 0, b = 3, c;
c = mul(a, b);
printf(“c = %d “, c);
return 0;
}/* Two return statements in the mul() function */
int mul(int a, int b)
{
if(a == 0 || b == 0)
{
return 0;
}
else
{
return (a * b);
}
}
Output:
c = 0 -
Question 16 of 20
16. Question
Usually recursion works slower than loops.
Correct
When a recursive call is made, the function/process clones itself and then process that funtion. This leads to time and space constrains.
In a loop, there is no recursive call involved that saves a lot of time and space too.
Incorrect
When a recursive call is made, the function/process clones itself and then process that funtion. This leads to time and space constrains.
In a loop, there is no recursive call involved that saves a lot of time and space too.
-
Question 17 of 20
17. Question
Maximum number of arguments that a function can take is 12
Correct
No, C can accept upto 127 maximum number of arguments in a function.
Incorrect
No, C can accept upto 127 maximum number of arguments in a function.
-
Question 18 of 20
18. Question
There is a error in the below program. Which statement will you add to remove it?
#include<stdio.h>
int main()
{
int a;
a = f(10, 3.14);
printf(“%d “, a);
return 0;
}
float f(int aa, float bb)
{
return ((float)aa + bb);
}Correct
The correct form of function f prototype is float f(int, float);
Incorrect
The correct form of function f prototype is float f(int, float);
-
Question 19 of 20
19. Question
Functions can not return a floating point number
Correct
A function can return floating point value.
Example:
#include <stdio.h>
float sub(float, float); /* Function prototype */int main()
{
float a = 4.5, b = 3.2, c;
c = sub(a, b);
printf(“c = %f “, c);
return 0;
}
float sub(float a, float b)
{
return (a – b);
}
Output:
c = 1.300000Incorrect
A function can return floating point value.
Example:
#include <stdio.h>
float sub(float, float); /* Function prototype */int main()
{
float a = 4.5, b = 3.2, c;
c = sub(a, b);
printf(“c = %f “, c);
return 0;
}
float sub(float a, float b)
{
return (a – b);
}
Output:
c = 1.300000 -
Question 20 of 20
20. Question
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
printf(“%p “, main());
return 0;
}Correct
In printf(“%p “, main()); it calls the main() function and then it repeats infinetly, untill stack overflow.
Incorrect
In printf(“%p “, main()); it calls the main() function and then it repeats infinetly, untill stack overflow.