Java C Functions Test 2 - Java C Functions Question and Answers
Finish Quiz
0 of 10 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Information
Let’s Play with our latest Java C Functions Test 2 and test your basic fundaments. Free Online Java C Functions Question and Answers. Free Java C Functions Quiz, Online Java, online Test Quiz 2. Java C Functions Quiz 2 Question and Answers 2024. Java online Test Quiz 2. Java C Functions Quiz 2 Free Mock Test 2024. Java C Functions Quiz 2 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 2 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 10 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
- Answered
- Review
-
Question 1 of 10
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 10
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 10
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 10
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 10
5. 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 6 of 10
6. 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 7 of 10
7. 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 8 of 10
8. 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 9 of 10
9. 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 10 of 10
10. 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.