Tag: programming languages

Questions Related to programming languages

Which header file do you need to include to use typecasting?

  1. stdin.h

  2. ctype.h

  3. math.h

  4. None


Correct Option: D

AI Explanation

To use typecasting in C/C++, you do not need to include any specific header file. Typecasting is a built-in feature of the C/C++ language and does not require any additional header files.

The correct answer is D) None.

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
  1. +public

  2. #protected

  3. !package

  4. -private


Correct Option: B
  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