GATE Questions

Q:

What is the difference between stack and array?

Answer

Stack:


 - Stack is a ordered collection of items


 - Stack is a dynamic object whose size is constantly changing as items are pushed and popped .


 - Stack may contain different data types


Array:


- Array is an ordered collection of items


- Array is a static object i.e. no of item is fixed and is assigned by the declaration of the array


- It contains same data types.

Report Error

View answer Workspace Report Error Discuss

Subject: C++ - Technology Exam Prep: GATE

10 4255
Q:

There are three rooms in a Hotel: one single, one double and one for four persons. How many ways are there to house seven persons in these rooms ?

A) 105 B) 7! x 6!
C) 7!/5! D) 420
 
Answer & Explanation Answer: A) 105

Explanation:

Choose 1 person for the single room & from the remaining choose 2 for the double room & from the remaining choose 4 people for the four person room,

Then, 7C1 x 6C2 x 4C4
     = 7 x  x 1
     = 7 x 15 = 105.
Report Error

View Answer Workspace Report Error Discuss

4 1544
Q:

Explain fork() system call?

Answer

The `fork()’ used to create a new process from an existing process. The new process is called the child process, and the existing process is called the parent. We can tell which is which by checking the return value from `fork()’. The parent gets the child’s pid returned to him, but the child gets 0 returned to him.

Report Error

View answer Workspace Report Error Discuss

Subject: Operating Systems Exam Prep: GATE

1 1415
Q:

Which among the following are not the c++ tokens

A) Identifiers B) keywords
C) Strings D) None
 
Answer & Explanation Answer: D) None

Explanation:

All the above listed options are c++ tokens .They  include:

             - keywords

             - Identifiers

             - Constants

             - Strings

             - operators

Report Error

View Answer Workspace Report Error Discuss

Filed Under: C++ - Technology
Exam Prep: GATE

2 1391
Q:

What is the output of this program?

class main_arguments {
            public static void main(String [ ] args)
            {
                String [][] argument = new String[2][2];
                int x;
                argument[0] = args;
                x = argument[0].length;
                for (int y = 0; y < x; y++)
                    System.out.print(" " + argument[0][y]);           
            }
        }

A) 1 1 B) 1 0
C) 1 0 3 D) 1 2 3
 
Answer & Explanation Answer: D) 1 2 3

Explanation:

In argument[0] = args;, the reference variable arg[0], which was referring to an array with two elements, is reassigned to an array (args) with three elements.
Output:
$ javac main_arguments.java
$ java main_arguments
1 2 3

Report Error

View Answer Workspace Report Error Discuss

Filed Under: Java - Technology
Exam Prep: GATE

0 1211