5
Q:

main() {

int i;

printf("%d",scanf("%d",&i)); // value 10 is given as input here

}

A) 1 B) 2
C) 3 D) 4

Answer:   A) 1



Explanation:

Scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1.

Subject: Java
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 Report Error Discuss

Filed Under: Java
Exam Prep: GATE

6 81142
Q:

Explain Overriding Polymorphism.?

Answer

Overriding means changing behavior of methods of base class in derive class by overriding the base class methods. If class A is a base class with method ’calculate’ and class B inherits class A, thus derives method ’calculate’ of class A. The behavior of ’calculate’ in class B can be changed by overriding it.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1579
Q:

When do you use :: Operator in C++?

Answer

:: is the scope resolution operator. When local variable and global variable are having same name, local variable gets the priority. C++ allows flexibility of accessing both the variables through a scope resolution operator

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1505
Q:

In RDBMS, what is the efficient data structure used in the internal storage representation?

A) Stack B) Queue
C) B+ tree structure D) AVL tree Structure
 
Answer & Explanation Answer: C) B+ tree structure

Explanation:

B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 6589
Q:

What are the types of Collision Resolution Techniques and the methods used in each of the type?

Answer

Open addressing (closed hashing),


The methods used include: Overflow block,


 Closed addressing (open hashing)


The methods used include: Linked list, Binary tree…

Report Error

View answer Workspace Report Error Discuss

Subject: Java

16 13060
Q:

Just by seeing the signature of the bean how can you specity whether it is a Statefull of Stateless Session Bean?

Answer

The create method in a stateless bean cannot have arguments, and can only have a single method called create(). While create in Stateful bean can have arguments and could be any method starting with create string eg. create(arg1, arg2, ...). Although it is not compiler checked but in stateless bean the ejb Passivate() and ejb Active() methods has to be empty as these functions are never called by EJB container. As conceptually in stateful session bean we might need to store the clients information hence arguments in createare necessary. While in stateless bean we don't hence no arguments are necessary. It's intutive isn't intutive isn't. I my life I haven't seen such a futuristic server programming tool as EJB.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 1492
Q:

Difference between Java Beans & Servlets?

Answer

java bean is a reusable component, where as the servlet is the java program which extends the server capability. 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

2 2238
Q:

What is Overloading Polymorphism?

Answer

Overloading allows multiple functions to exist with same name but different parameters. Again if you take bike as an example, it has a function “Start” with two forms i.e. ’Auto Start’ and ’kick start’.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2331