CS304 Quiz Object-Oriented Programming Concepts and Operators Quiz

Object-Oriented Programming Concepts and Operators Quiz

Question #1:

In C++, Composition is a relationship between ____________ and _______________ objects.

Options:

A) Base, derived

B) Parent, child

C) Whole, part

D) All given options are correct.

Correct Option: D


Question #2:

Composition is __________ and aggregation is ____________ relationship.

Options:

A) Weak, Weak

B) Weak, Strong

C) Strong, Weak

D) Strong, Strong

Correct Option: C


Question #3:

Static Data Members can be accessed through _________.

Options:

A) Dot operator

B) Dot operator and scope resolution operator

C) Semi colon

D) Scope resolution operator

Correct Option: A


Question #4:

Which of the following operators operate on one operand?

Options:

A) Unary Operators

B) Binary Operators

C) Ternary Operator

D) All of the given options

Correct Option: A


Question #5:

_______ remain in memory even when all objects of a class have been destroyed.

Options:

A) Constant Data Members

B) Instance Data Members

C) Primitive Variables

D) Static Data Members

Correct Option: D


Question #6:

Which of the following best describes the relationship between Book and BookChapter classes?

Options:

A) Aggregation

B) Composition

C) Inheritance

D) Association

Correct Option: D


Question #7:

We can get the address of a variable stored in a pointer using __________.

Options:

A) & symbol

B) :: symbol

C) -> symbol

D) * symbol

Correct Option: A


Question #8:

In which of the following OOP paradigms objects cannot exist independently?

Options:

A) Inheritance

B) Polymorphism

C) Aggregation

D) Composition

Correct Option: D


Question #9:

Choose the correct option to declare an overloaded stream insertion operator for a user-defined class "String" as a non-member friend function.

Options:

A) friend ostream & operator << (ostream & os, const String & s);

B) friend ostream & operator << ();

C) friend void & operator << (ostream & os);

D) friend void operator << (const String & rhs)

Correct Option: A


Question #10:

If you do not initialize a static data member of a class of int type, it is automatically initialized with _________.

Options:

A) Null

B) 0-32767

C) 0

Correct Option: C



Contact Us for Vu LMS Handling      Click Here



cs304 solved MCQ's by vugetready

Question #1:

Which type of rotation can balance the following AVL tree?

A) Double right-left

B) Double left-right

C) Single right

D) Single left

Correct option: C) Single right


Question #2:

Which of the following function prototypes declares the function as constant?

A) void EType& findMin(const int a);

B) const EType& findMin();

C) EType& findMin(const int a);

D) const EType& findMin() const;

Correct option: D) const EType& findMin() const;


Question #3:

In the given BST, the balance factor of the root node is:

A) 0

B) -2

C) 1

D) -1

Correct option: A) 0


Question #4:

If values 10, 20, 15 are used to build an AVL tree, which type of rotation can balance the AVL tree?

A) Double right-left

B) Single right

C) Double left-right

D) Single left

Correct option: B) Single right


Question #5:

Which data structure will be used to avoid the problems caused by the BST generated using sorted data?

A) AVL Tree

B) Linked list

C) Queue

D) Stack

Correct option: A) AVL Tree


Question #6:

Which of the following will be used to avoid the problems caused by the BST generated using sorted data?

A) AVL Tree

B) Linked list

C) Queue

D) Stack

Correct option


: A) AVL Tree


Question #7:

Which function is returning a const value?

A) void EType& findMin(const int a) const;

B) int EType& findMin() const;

C) const EType& findMin() const;

D) void EType& findMin(const int a);

Correct option: C) const EType& findMin() const;


Question #8:

If a BST is generated from the data sorted in ascending or descending order, then its traversal will be similar to:

A) Complete Binary Tree

B) AVL tree

C) Strictly Binary Tree

D) Linked List

Correct option: D) Linked List


Question #9:

What will be the height of an empty AVL tree?

A) 0

B) 2

C) 1

D) -1

Correct option: A) 0


Question #10:

The balance of a node in a binary search tree is defined as the __________________.

A) Height of its left subtree - height of its right subtree

B) Height of its right subtree + height of its left subtree

C) Height of its left subtree - height of its leaf nodes

D) Height of its right subtree - height of root node

Correct option: A) Height of its left subtree - height of its right subtree


Contact Us for YT Monetization      Click Here


CS304 Solved MCSQ's Midter Preparation by Munir

Option 1:

Question: What will be the output of the following code segment?

```cpp

int value = 1;

switch (value + value) {

    case 1:

        cout << "Punjab ";

        break;

    case 2:

        cout << "Lahore";

        break;

    default:

        cout << "Pakistan";

}

```

Option 1: Syntax error

Option 2: Lahore

Option 3: Punjab

Option 4: Pakistan

Correct Answer: Option 2 (Lahore)


Option 2:

Question: = operator is used for _______.

Option 1: Comparison

Option 2: Checking equality

Option 3: Assigning values to variables

Option 4: Decision making

Correct Answer: Option 3 (Assigning values to variables)


Option 3:

Question: Which of the following will be the most appropriate data type to store the value 63.547?

Option 1: Short

Option 2: Character

Option 3: Integer

Option 4: Float

Correct Answer: Option 4 (Float)


Option 4:

Question: How we declare an array of integer data whose size is 20 with array name "count"?

Option 1: int count[20];

Option 2: int count[19];

Option 3: int count[21];

Option 4: float count[20];

Correct Answer: Option 1 (int count[20];)


Option 5:

Question: If we pass more than one arguments to a function, then they are separated by ___________.

Option 1: Comma ,

Option 2: Semicolon ;

Option 3: Colon :

Option 4: Double quotes "

Correct Answer: Option 1 (Comma ,)


Option 6:

Question: _________ operator is used to pass the address of a variable in the call by reference method.

Option 1: +

Option 2: &

Option 3: @

Option 4: %

Correct Answer: Option 2 (&)


Option 7:

Question: __________ will be used for enclosing function statements into a block.

Option 1: ()

Option 2: {}

Option 3: ""

Option 4: []

Correct Answer: Option 2 ({})


Option 8:

Question: The continue statement usually forces the immediate _____ iteration of the loop.

Option 1: Previous

Option 2: Next

Option 3: First

Option 4: Last

Correct Answer: Option 2 (Next)


Option 9:

Question: What will be the output of the following code?

```cpp

string name[4] = {"Ali", "Bilal", "Omer", "Ayesha"};

cout << name[2];

```

Option 1: Omer

Option 2: Ayesha

Option 3: Bilal

Option 4: Ali

Correct Answer: Option 1 (Omer)


Option 10:

Question: What will be the output of the following code segment?

```cpp

for (int i = 2; i < 10; i++) {

    if (i == 5)

        continue;

    cout << i << ",";

}

```

Option 1: 2,3,4,6,7,8,9,

Option 2: 4,7,9,

Option 3: 2,3,7,8,

Option 4: 2,3,4,6,7,8,9,10,

Correct Answer: Option 1 (2,3,4,6,7,8,9,)