3i Infotech Papers: Sample Questions 1163 - 1165 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 1163

» Languages » Java

Appeared in Year: 2004

MCQ▾

Question

Which of the following is correct syntax for an Abstract class?

Choices

Choice (4) Response

a.

Abstract double area

b.

Abstract double area

c.

Abstract double area

d.

Abstract double area

Answer

d.

Explanation

Understanding of abstract class.

Understanding of Abstract Class.

Understanding of abstract class.

  • Abstraction hides implementation details.

  • Abstraction lets the user focus on what the object does instead of how it does it.

    There are two ways to achieve abstraction in java

  • Abstract class

  • Interface

Syntax of Abstract Class

modifier abstract class className

  1. {
  2.     abstract datatype methodName();
  3.     // abstract double area ();
  4. }
  5. modifier class childclass Extend className
  6. {
  7.     abstract datatype methodName(){}
  8. }

Question number: 1164

» Languages » C & C Plus Plus

Short Answer Question▾

Write in Short

To which numbering system can the binary number 1101100100111100 be easily converted to?

Explanation

  • This is a 16 bit number.

  • We can group these bits into 4 bits a group.

    (1101) (1001) (0011) (1100)

  • Given set of bits can converted to HEXA DECIMAL SYSTEM

  • (D93C)

Question number: 1165

» Languages » Java

Essay Question▾

Describe in Detail

Write down how will you create a binary tree?

Explanation

Binary tree have an elegant recursive pointer structure allowing recursive pointer algorithms.

Code of binary search tree:

  1. class BinarySearchTree
  2. {
  3.     class Node
  4.     {
  5.         int key;
  6.         Node leftright;
  7.         public Node(int item) {
  8.             key = item;
  9.             left = right = null;
  10.         }
  11.     }
  12.     Node root;
  13.     BinarySearchTree()
  14.     {
  15.         root = null;
  16.     }
  17.     void insert(int key)
  18.     {
  19.         root = insertRec(rootkey);
  20.     }
  21.     Node insertRec(Node rootint key)
  22.     {
  23.         if (root == null)
  24.         {
  25.             root = new Node(key);
  26.             return root;
  27.         }
  28.         if (key < root.key)
  29.         root.left = insertRec(root.leftkey);
  30.         else if (key > root.key)
  31.         root.right = insertRec(root.rightkey);
  32.         return root;
  33.     }
  34.     void inorder()
  35.     {
  36.         inorderRec(root);
  37.     }
  38.     void inorderRec(Node root)
  39.     {
  40.         if (root != null)
  41.         {
  42.             inorderRec(root.left);
  43.             System.out.println(root.key);
  44.             inorderRec(root.right);
  45.         }
  46.     }
  47.     public static void main(String[] args)
  48.     {
  49.         BinarySearchTree tree = new BinarySearchTree();
  50.         tree.inorder();
  51.     }
  52. }

Output:

Insert data: 50,30,20,40,70,60,80

Output: 20,30,40,50,60,70,80