0

programming languages Online Quiz - 264

Description: programming languages Online Quiz - 264
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Which conversion is not possible?

  1. int to float

  2. float to int

  3. char to float

  4. All are possible


Correct Option: D

AI Explanation

To answer this question, we need to understand the concept of type conversion in programming.

Type conversion refers to the process of converting a value from one data type to another. In most programming languages, certain conversions are allowed, while others may not be possible or may result in loss of information.

Let's go through each option to understand why it is correct or incorrect:

Option A) int to float - This option is possible because it involves converting an integer value to a floating-point value. This conversion is allowed, and the integer value can be represented as a floating-point number.

Option B) float to int - This option is possible because it involves converting a floating-point value to an integer value. This conversion is allowed, but it may result in the loss of the decimal part of the floating-point value.

Option C) char to float - This option is possible because it involves converting a character value to a floating-point value. This conversion is allowed, and the character can be represented as its corresponding ASCII value, which can be stored as a floating-point number.

Option D) All are possible - This option is incorrect because there is one conversion that is not possible. The correct answer is D because not all conversions are possible.

The correct answer is D. This option is incorrect because there is one conversion that is not possible.

Which of the following statement is correct?

  1. Classes in class diagrams may be grouped into packages in order to illustrate the overall organization of a model

  2. In object diagrams, names of instances are in italics or all-caps

  3. If package B depends on package A, then any change in A will require a change in B

  4. Object diagrams and class diagrams are completely interchangeable


Correct Option: A

Advantage of using polymorphism in class diagrams is a reduction of

  1. methods in the associated classes

  2. subclasses needed to accomplish the same functionality

  3. case statements and conditionals

  4. coupling between classes in the system


Correct Option: C

Symbol for a component inside a deployment diagram?

  1. Components are not allowed in deployment diagrams

  2. A rounded rectangle, just like a state in a state diagram

  3. A 3-dimensional rectangular solid (like a box)

  4. A rectangle with tabs on its left side


Correct Option: D

Wrong pair of symbol-visibility scope ?

  1. +public

  2. #protected

  3. !package

  4. -private


Correct Option: B

which of the following statements are true about use cases ?

  1. Use cases cannot be traced to a goal

  2. Use cases can be traced to atleast one goal

  3. Use cases are always traceable to multiple goals

  4. Use cases are not object oriented


Correct Option: B,D

When creating Use cases,the mapping between external event and Goal can be N:1

  1. True

  2. False


Correct Option: A

A deployment diagram does not address a static view of a system

  1. True

  2. False


Correct Option: B

A colloboration diagram can express both structural and behavioural aspects of a system

  1. True

  2. False


Correct Option: A

Can a static variable be Serialized

  1. True

  2. False


Correct Option: B

Which of the following pairs is not supported in Java

  1. Multiple Inheritance and Overloading

  2. Operator Overloading and Overriding

  3. Multiple Inheritance and Operator Overloading

  4. Pointers and Single Inheritance


Correct Option: C

What will be the output of the following program : #define Swap if (a != b) { \ temp=a; \ a = b; \ b = temp; \ //Swapping Done } void main() { int a=10,b=5,temp; Swap; printf("a=%d a=%d",a,b); }

  1. Compile-Time Error

  2. a=5 b=10

  3. a=10 b=5

  4. None of the above


Correct Option: A

What will be the output of the following program : void main() { int val=50; void ptr; ptr=&val; printf("%d %d",val,(int *)ptr); }C

  1. Compile-Time Error

  2. 50 50

  3. 50 0

  4. None of the above


Correct Option: B

What will be the output of the following program : void main() { int a=5,b=6; Printf("%d %d %d",a,b,--a*++b); }

  1. Compile-Time Error

  2. 5 6 30

  3. 4 7 28

  4. None of the above


Correct Option: C

What will be the output of the following program : void main() { int val=5; void ptr; *(int *)ptr=5; val=ptr; printf("%d %d",(int )val,(int *)ptr); }

  1. Compile-Time Error

  2. Unpredictable

  3. 5 5

  4. None of the above


Correct Option: C

AI Explanation

To answer this question, let's go through the given program step by step:

  1. The program starts by declaring a variable val and initializing it with the value 5.
  2. Then, a void pointer ptr is declared.
  3. The next line *(int *)ptr=5; tries to assign the value 5 to the memory location pointed by ptr. However, since ptr is not pointing to any valid memory location, this line will result in undefined behavior. This is because ptr is uninitialized and pointing to an unknown memory location.
  4. Next, the line val=ptr; tries to assign the value of ptr to val. Since ptr is uninitialized, this will also result in undefined behavior.
  5. Finally, the line printf("%d %d",*(int *)val,*(int *)ptr); tries to print the values at the memory locations pointed by val and ptr. However, since both val and ptr are uninitialized and not pointing to valid memory locations, this will also result in undefined behavior.

Therefore, the correct answer is option A) Compile-Time Error.

What will be the output of the following program : void main() { int val=2; val = - --val- val--- --val; printf("%d",val); }

  1. Compile-Time Error

  2. 3

  3. -1

  4. 0


Correct Option: C

What will be the output of the following program : void main() { int i, n =10; for (i=1; i

  1. 84

  2. 840

  3. 852

  4. 864


Correct Option: C

What will be the output of the following program : void main() { printf("%f",123.); }

  1. 123

  2. Compile-Time Error

  3. 123.00

  4. 123.000000


Correct Option: D

AI Explanation

To answer this question, let's go through the options one by one:

Option A) 123 - This option is incorrect because the code includes a format specifier "%f" in the printf function. This format specifier is used to print floating-point numbers, and it specifies that the number should be printed with six digits after the decimal point.

Option B) Compile-Time Error - This option is incorrect. The code does not contain any syntax errors, so it will compile successfully.

Option C) 123.00 - This option is incorrect. Although the number 123 is a whole number, the format specifier "%f" specifies that the number should be printed with six digits after the decimal point. Since there are no digits after the decimal point in the number 123., it will be printed as 123.000000.

Option D) 123.000000 - This option is correct. The code includes a format specifier "%f" in the printf function, which specifies that the number should be printed with six digits after the decimal point. Since there are no digits after the decimal point in the number 123., it will be printed as 123.000000.

The correct answer is D) 123.000000.

What will be the output of the following program : void main() { printf("%d",sizeof(integer)); }

  1. 2

  2. 4

  3. Compile-Time Error

  4. None of the above


Correct Option: C
- Hide questions