Languages [TCS Placement]: Sample Questions 115 - 117 of 131

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 115

Edit

Describe in Detail

Essay▾

What are binary trees?

Explanation

  • Binary trees extended the concept of linked lists.
  • A binary tree has two pointers, a left one and a right one. Each side can further branch into two additional nodes with each node having two pointers as well.
  • A “binary search tree” (BST) or “ordered binary tree” is a type of binary tree where the nodes are arranged in order: for each node, all elements in left subtree are less-or-equal to the node (<=) , and all the elements in right subtree are greater than the node (>) .
Given the Image is Define the Binary Tree Example

Question 116

Edit

Write in Short

Short Answer▾

Which special symbol is allowed in a variable name?

Explanation

  • Variable names in C are made up of letters (upper and lower case) and digits. The underscore character ( “_” ) is also permitted. Names must not begin with a digit.
  • Examples of C variable names: foo, Bar, BAZ, foo_bar, _foo42, _QuUx

Question 117

Question

MCQ▾

For automatic objects, constructors and destructors are called each time the objects

Choices

Choice (4)

a.

Enter and leave scope

b.

Inherit parent class

c.

Are constructed

d.

Are destroyed

Answer

a.

Explanation

  • For automatic objects, constructors and destructors are called each time the objects enter and leave scope
  • Automatic variables are those, which exist only within the scope where they are declared- typically allocated on stack
  • Constructor and destructors are called implicitly by the compiler.
  • The order in which these function calls occur depends on the order in which execution enters and leaves the scopes where the objects are instantiated.
  • Constructor for an automatic local object is called when execution reaches the point where that object is defined the corresponding destructor is called when execution leaves the object՚s scope.
  • Constructor and destructor for automatic objects are called each time execution enters and leaves the scope of the object.
  • Destructors are not called for automatic objects if the program terminates with a call to function exit or function abort.

Developed by: