0

programming languages Online Quiz - 252

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

If you write a class with no constructors; the compiler will automatically supplies a no-argument(default)constructors

  1. True

  2. False


Correct Option: A

constructors can be overloaded but can't be overridden and constructors cannot be inherited.

  1. True

  2. False


Correct Option: A

If a constructor uses super, it must use it in the first line; otherwise, the compiler will complain.

  1. True

  2. False


Correct Option: A
  1. "X extends Y" is correct if and only if X is a class and Y is an interface

  2. "X extends Y" is correct if and only if X and Y are either both classes or both interfaces

  3. "X extends Y" is correct if and only if X is an interface and Y is a class

  4. None of these


Correct Option: B

A local variable with the same name as an instance variable

  1. shadowing

  2. Coupling

  3. Cohesion

  4. None of the above


Correct Option: A
  1. Interface can extend one or more interfaces

  2. Interface can extend one or more class

  3. Interface cannot implement a class or interface

  4. All of the above


Correct Option: A

State which stament is true?

  1. Cohesionn is the OO principle most closely associated with hiding implementation details

  2. Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs

  3. None of these

  4. Cohesion is the OO principle most closely associated with making sure that a class is designed witha single well focussed principle


Correct Option: D

AI Explanation

To answer this question, we need to understand the concept of cohesion in object-oriented programming (OO).

Cohesion refers to how closely the responsibilities and behaviors of a class or module are related. It is a measure of how well a class or module is focused on a single purpose or responsibility.

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

Option A) Cohesion is the OO principle most closely associated with hiding implementation details. This option is incorrect because hiding implementation details is more closely associated with the principle of encapsulation, not cohesion.

Option B) Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs. This option is incorrect because the principle described here is actually related to the concept of loose coupling, not cohesion.

Option C) None of these. This option is incorrect because there is a correct answer among the given options.

Option D) Cohesion is the OO principle most closely associated with making sure that a class is designed with a single well-focused purpose. This option is correct because cohesion is indeed the principle associated with ensuring that a class has a clear and specific responsibility.

Therefore, the correct answer is D) Cohesion is the OO principle most closely associated with making sure that a class is designed with a single well-focused principle.

  1. Will not compile

  2. Will compile without error but not run

  3. Will compile with warnings but run ok

  4. Will compile with warnings, but not run


Correct Option: C

See the code below and select the correct answer: #include main() { int i; printf ("enter integer: "); scanf ("%d",&i); printf ("You have entered: %f ", i); return (0); }

  1. Will not compile

  2. Will compile but not run

  3. Will give an output of 1

  4. Will give an output of 1.000000


Correct Option: B

See the code below and select the correct answer: #include #include #include main() { clrscr(); int i; printf ("enter integer: "); scanf ("%d",&i); printf ("You have entered: %d ", i); getch(); return (0); }

  1. Will not compile

  2. Will compile with warning, and run

  3. Will compile but not run

  4. Will provide an output 1


Correct Option: A

The output of the above code is 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

  1. True

  2. False


Correct Option: A

The code below will go into infinite loop: #include #include #include main() { int i=0, j=0; clrscr(); for (i=0; i<5;i++) { for (j=i; j<=0; j--) { printf ("1\t"); } printf("\n"); } getch(); return (0); }

  1. True

  2. False


Correct Option: B

Note the following code and then select the correct answer: #include main() { int i; printf ("enter integer: "); scanf ("%d",&i); printf ("You have entered: %f ", i); return (0); }

  1. Will not compile

  2. Will compile with warnings, but run

  3. Will compile without warning, but not run

  4. Will give an output of 1


Correct Option: C

Note the code below and select the correct answer: #include main() { printf ("hello world"); }

  1. Will not compile

  2. Will compile without error or warning and run ok

  3. Will compile without error or warning but not run

  4. Will compile with warning but run ok


Correct Option: D

we can not override a synchronized method as non-synchronized method.

  1. True

  2. False


Correct Option: B
- Hide questions