## Java C Expression Quiz 1 | Java C Expression 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

**Java C Expression Quiz 1 | Java C Expression Question and Answers**. Test your Java basic fundamentals with our Free Java C Expression online test. The above test is fully free and there are no charges to take this test. Java C Expression Quiz 1 Question and Answers 2017. Java online Test Quiz 1. Java C Expression Quiz 1 Free Mock Test 2017. **Java C Expression 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 Expression Quiz 1 Question and Answers in English. Java C Expression Mock test for topic via C Expression Mode. Here we are providing** Java C Expression Quiz in English** Now Test your self for “**C Expression Online Quiz in English**” Exam by using below quiz…

This paper has **20 questions**.

Time allowed is **25 minutes**.

The **Java C Expression 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

Which of the following is the correct order of evaluation for the below expression?

z = x + y * z / 4 % 2 – 1CorrectC uses left associativity for evaluating expressions to break a tie between two operators having same precedence.

IncorrectC uses left associativity for evaluating expressions to break a tie between two operators having same precedence.

- Question 2 of 20
##### 2. Question

In which order do the following gets evaluated

1. Relational

2. Arithmetic

3. Logical

4. AssignmentCorrect2. Arithmetic operators: *, /, %, +, –

1. Relational operators: >, <, >=, <=, ==, !=

3. Logical operators : !, &&, ||

4. Assignment operators: =Incorrect2. Arithmetic operators: *, /, %, +, –

1. Relational operators: >, <, >=, <=, ==, !=

3. Logical operators : !, &&, ||

4. Assignment operators: = - Question 3 of 20
##### 3. Question

Associativity has no role to play unless the precedence of operator is same.

CorrectIncorrect - Question 4 of 20
##### 4. Question

Which of the following correctly shows the hierarchy of arithmetic operations in C?

CorrectSimply called as BODMAS (Bracket of Division, Multiplication, Addition and Subtraction).

How Do I Remember ? BODMAS !

B – Brackets first

O – Orders (ie Powers and Square Roots, etc.)

DM – Division and Multiplication (left-to-right)

AS – Addition and Subtraction (left-to-right)IncorrectSimply called as BODMAS (Bracket of Division, Multiplication, Addition and Subtraction).

How Do I Remember ? BODMAS !

B – Brackets first

O – Orders (ie Powers and Square Roots, etc.)

DM – Division and Multiplication (left-to-right)

AS – Addition and Subtraction (left-to-right) - Question 5 of 20
##### 5. Question

Which of the following are unary operators in C?

1. !

2. sizeof

3. ~

4. &&CorrectAn operation with only one operand is called unary operation.

Unary operators:

! Logical NOT operator.

~ bitwise NOT operator.

sizeof Size-of operator.

&& Logical AND is a logical operator.Therefore, 1, 2, 3 are unary operators.

IncorrectAn operation with only one operand is called unary operation.

Unary operators:

! Logical NOT operator.

~ bitwise NOT operator.

sizeof Size-of operator.

&& Logical AND is a logical operator.Therefore, 1, 2, 3 are unary operators.

- Question 6 of 20
##### 6. Question

The expression of the right hand side of || operators does not get evaluated if the left hand side determines the outcome.

CorrectBecause, if a is non-zero then b will not be evaluated in the expression (a || b)

IncorrectBecause, if a is non-zero then b will not be evaluated in the expression (a || b)

- Question 7 of 20
##### 7. Question

Associativity of an operator is either Left to Right or Right to Left.

CorrectYes, the associativity of an operator is either Left to Right or Right to Left.

IncorrectYes, the associativity of an operator is either Left to Right or Right to Left.

- Question 8 of 20
##### 8. Question

Which of the following is the correct usage of conditional operators used in C?

CorrectOption A: assignment statements are always return in paranthesis in the case of conditional operator. It should be a>b? (c=30):(c=40);

Option B: it is syntatically wrong.

Option D: syntatically wrong, it should be return(a>b ? a:b);

Option C: it uses nested conditional operator, this is logic for finding greatest number out of three numbers.IncorrectOption A: assignment statements are always return in paranthesis in the case of conditional operator. It should be a>b? (c=30):(c=40);

Option B: it is syntatically wrong.

Option D: syntatically wrong, it should be return(a>b ? a:b);

Option C: it uses nested conditional operator, this is logic for finding greatest number out of three numbers. - Question 9 of 20
##### 9. Question

In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators

CorrectThe equal to = operator has Right-to-Left Associativity. So it assigns b=5 then a=b.

IncorrectThe equal to = operator has Right-to-Left Associativity. So it assigns b=5 then a=b.

- Question 10 of 20
##### 10. Question

Which of the following is the correct order if calling functions in the below code?

a = f1(23, 14) * f2(12/4) + f3();CorrectHere, Multiplication will happen before the addition, but in which order the functions would be called is undefined. In an arithmetic expression the parenthesis tell the compiler which operands go with which operators but do not force the compiler to evaluate everything within the parenthesis first.

IncorrectHere, Multiplication will happen before the addition, but in which order the functions would be called is undefined. In an arithmetic expression the parenthesis tell the compiler which operands go with which operators but do not force the compiler to evaluate everything within the parenthesis first.

- Question 11 of 20
##### 11. Question

Will the expression *p = p be disallowed by the compiler?

CorrectBecause, here even though the value of p is accessed twice it is used to modify two different objects p and *p

IncorrectBecause, here even though the value of p is accessed twice it is used to modify two different objects p and *p

- Question 12 of 20
##### 12. Question

What will be the output of the program?

#include<stdio.h>

int main()

{

int i=-3, j=2, k=0, m;

m = ++i && ++j && ++k;

printf(“%d, %d, %d, %d “, i, j, k, m);

return 0;

}CorrectStep 1: int i=-3, j=2, k=0, m; here variable i, j, k, m are declared as an integer type and variable i, j, k are initialized to -3, 2, 0 respectively.

Step 2: m = ++i && ++j && ++k;

becomes m = -2 && 3 && 1;

becomes m = TRUE && TRUE; Hence this statement becomes TRUE. So it returns 1(one). Hence m=1.

Step 3: printf(“%d, %d, %d, %d “, i, j, k, m); In the previous step the value of i,j,k are incremented by 1(one).Hence the output is “-2, 3, 1, 1”.

IncorrectStep 1: int i=-3, j=2, k=0, m; here variable i, j, k, m are declared as an integer type and variable i, j, k are initialized to -3, 2, 0 respectively.

Step 2: m = ++i && ++j && ++k;

becomes m = -2 && 3 && 1;

becomes m = TRUE && TRUE; Hence this statement becomes TRUE. So it returns 1(one). Hence m=1.

Step 3: printf(“%d, %d, %d, %d “, i, j, k, m); In the previous step the value of i,j,k are incremented by 1(one).Hence the output is “-2, 3, 1, 1”.

- Question 13 of 20
##### 13. Question

What will be the output of the program?

#include<stdio.h>

int main()

{

int i=-3, j=2, k=0, m;

m = ++i || ++j && ++k;

printf(“%d, %d, %d, %d “, i, j, k, m);

return 0;

}CorrectStep 1: int i=-3, j=2, k=0, m; here variable i, j, k, m are declared as an integer type and variable i, j, k are initialized to -3, 2, 0 respectively.

Step 2: m = ++i || ++j && ++k; here (++j && ++k;) this code will not get executed because ++i has non-zero value.

becomes m = -2 || ++j && ++k;

becomes m = TRUE || ++j && ++k; Hence this statement becomes TRUE. So it returns (one). Hence m=1.

Step 3: printf(“%d, %d, %d, %d “, i, j, k, m); In the previous step the value of variable i only incremented by 1(one). The variable j,k are not increemented.Hence the output is “-2, 2, 0, 1”.

IncorrectStep 2: m = ++i || ++j && ++k; here (++j && ++k;) this code will not get executed because ++i has non-zero value.

becomes m = -2 || ++j && ++k;

becomes m = TRUE || ++j && ++k; Hence this statement becomes TRUE. So it returns (one). Hence m=1.

Step 3: printf(“%d, %d, %d, %d “, i, j, k, m); In the previous step the value of variable i only incremented by 1(one). The variable j,k are not increemented.Hence the output is “-2, 2, 0, 1”.

- Question 14 of 20
##### 14. Question

Two different operators would always have different Associativity.

CorrectNo, Two different operators may have same associativity.

Example:

Arithmetic operators like ++, — having Right-to-Left associativity.

Relational operators like >, >= also have Left-to-Right associativity.IncorrectNo, Two different operators may have same associativity.

Example:

Arithmetic operators like ++, — having Right-to-Left associativity.

Relational operators like >, >= also have Left-to-Right associativity. - Question 15 of 20
##### 15. Question

What will be the output of the program?

#include<stdio.h>

int main()

{

int x=12, y=7, z;

z = x!=4 || y == 2;

printf(“z=%d “, z);

return 0;

}CorrectStep 1: int x=12, y=7, z; here variable x, y and z are declared as an integer and variable x and y are initialized to 12, 7 respectively.

Step 2: z = x!=4 || y == 2;

becomes z = 12!=4 || 7 == 2;

then z = (condition true) || (condition false); Hence it returns 1. So the value of z=1.Step 3: printf(“z=%d “, z); Hence the output of the program is “z=1”.

IncorrectStep 1: int x=12, y=7, z; here variable x, y and z are declared as an integer and variable x and y are initialized to 12, 7 respectively.

Step 2: z = x!=4 || y == 2;

becomes z = 12!=4 || 7 == 2;

then z = (condition true) || (condition false); Hence it returns 1. So the value of z=1.Step 3: printf(“z=%d “, z); Hence the output of the program is “z=1”.

- Question 16 of 20
##### 16. Question

Are the following two statement same?

1. a <= 20 ? (b = 30): (c = 30);

2. (a <=20) ? b : (c = 30);CorrectNo, the expressions 1 and 2 are not same.

1. a <= 20 ? (b = 30) : (c = 30); This statement can be rewritten as,

if(a <= 20)

{

b = 30;

}

else

{

c = 30;

}

2. (a <=20) ? b : (c = 30); This statement can be rewritten as,if(a <= 20)

{

//Nothing here

}

else

{

c = 30;

}IncorrectNo, the expressions 1 and 2 are not same.

1. a <= 20 ? (b = 30) : (c = 30); This statement can be rewritten as,

if(a <= 20)

{

b = 30;

}

else

{

c = 30;

}

2. (a <=20) ? b : (c = 30); This statement can be rewritten as,if(a <= 20)

{

//Nothing here

}

else

{

c = 30;

} - Question 17 of 20
##### 17. Question

What will be the output of the program?

#include<stdio.h>

int main()

{

static int a[20];

int i = 0;

a[i] = i ;

printf(“%d, %d, %d “, a[0], a[1], i);

return 0;

}CorrectStep 1: static int a[20]; here variable a is declared as an integer type and static. If a variable is declared as static and it will ne automatically initialized to value 0(zero).

Step 2: int i = 0; here vaiable i is declared as an integer type and initialized to 0(zero).

Step 3: a[i] = i ; becomes a[0] = 0;

Step 4: printf(“%d, %d, %d “, a[0], a[1], i);

Here a[0] = 0, a[1] = 0(because all staic variables are initialized to 0) and i = 0.

Step 4: Hence the output is “0, 0, 0”.IncorrectStep 1: static int a[20]; here variable a is declared as an integer type and static. If a variable is declared as static and it will ne automatically initialized to value 0(zero).

Step 2: int i = 0; here vaiable i is declared as an integer type and initialized to 0(zero).

Step 3: a[i] = i ; becomes a[0] = 0;

Step 4: printf(“%d, %d, %d “, a[0], a[1], i);

Here a[0] = 0, a[1] = 0(because all staic variables are initialized to 0) and i = 0.

Step 4: Hence the output is “0, 0, 0”. - Question 18 of 20
##### 18. Question

Assunming, integer is 2 byte, What will be the output of the program?

#include<stdio.h>

int main()

{

printf(“%x “, -2<<2);

return 0;

}CorrectThe integer value 2 is represented as 00000000 00000010 in binary system.

Negative numbers are represented in 2´s complement method.1´s complement of 00000000 00000010 is 11111111 11111101 (Change all 0s to 1 and 1s to 0).

2´s complement of 00000000 00000010 is 11111111 11111110 (Add 1 to 1´s complement to obtain the 2´s complement value).Therefore, in binary we represent -2 as: 11111111 11111110.

After left shifting it by 2 bits we obtain: 11111111 11111000, and it is equal to “fff8” in hexadecimal system.IncorrectThe integer value 2 is represented as 00000000 00000010 in binary system.

Negative numbers are represented in 2´s complement method.1´s complement of 00000000 00000010 is 11111111 11111101 (Change all 0s to 1 and 1s to 0).

2´s complement of 00000000 00000010 is 11111111 11111110 (Add 1 to 1´s complement to obtain the 2´s complement value).Therefore, in binary we represent -2 as: 11111111 11111110.

After left shifting it by 2 bits we obtain: 11111111 11111000, and it is equal to “fff8” in hexadecimal system. - Question 19 of 20
##### 19. Question

What will be the output of the program?

#include

int main()

{

int a=100, b=200, c;

c = (a == 100 || b > 200);

printf(“c=%d “, c);

return 0;

}CorrectStep 1: int a=100, b=200, c;

Step 2: c = (a == 100 || b > 200);

becomes c = (100 == 100 || 200 > 200);

becomes c = (TRUE || FALSE);

becomes c = (TRUE);(ie. c = 1)

Step 3: printf(“c=%d “, c); It prints the value of variable i=1

Hence the output of the program is 1(one).IncorrectStep 1: int a=100, b=200, c;

Step 2: c = (a == 100 || b > 200);

becomes c = (100 == 100 || 200 > 200);

becomes c = (TRUE || FALSE);

becomes c = (TRUE);(ie. c = 1)

Step 3: printf(“c=%d “, c); It prints the value of variable i=1

Hence the output of the program is 1(one). - Question 20 of 20
##### 20. Question

Every operator has an Associativity

CorrectYes, Each and every operator has an associativity.

The associativity (or fixity) of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses. Operators may be left-associative, right-associative or non-associative.

IncorrectYes, Each and every operator has an associativity.

The associativity (or fixity) of an operator is a property that determines how operators of the same precedence are grouped in the absence of parentheses. Operators may be left-associative, right-associative or non-associative.