Friday, 30 September 2011

What is the difference between the instanceof and getclass, these two are same or not ?

instanceof is a operator, not a function while getClass is a method of java.lang.Object class. Consider a condition where we use
if(o.getClass().getName().equals(“java.lang.Math”)){ }
This method only checks if the classname we have passed is equal to

Friday, 23 September 2011

Expain the reason for each keyword of public static void main(String args[])?

public- main(..) is the first method called by java environment when a program is executed so it has to accessible from java environment. Hence the access specifier has to be public.

static: Java environment should be able to call this method without creating an instance of the class , so this method must be declared as static.

What is a view? How it is related to data independence?

A view may be thought of as a virtual table, that is, a table that does not really exist in its own right but is instead derived from one or more underlying base table. In other words,

Describe the three levels of data abstraction?

The are three levels of abstraction:

  • Physical level: The lowest level of abstraction describes how data are stored.

  • Logical level: The next higher level of abstraction, describes what data are stored in database and what relationship among those data.

  • View level: The highest level of abstraction describes only part of entire database.

Predict the output or error(s) for the following:

main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;

for(j=0;j<5;j++) {
printf(” %d “,*c);
++q;     }

for(j=0;j<5;j++){

printf(” %d “,*p);

++p;     }
}

Answer:

2 2 2 2 2 2 3 4 6 5

Explanation: 

Predict the output or error(s) for the following:

main()

            {

            static int var = 5;

            printf(“%d “,var–);

            if(var)

                        main();

            }

Answer:

5 4 3 2 1

Explanation:

When static storage class is given, it is initialized once. The change in the value of

Predict the output or error(s) for the following:

main()

{

            float me = 1.1;

            double you = 1.1;

            if(me==you)

printf(“I love U”);

else

                        printf(“I hate U”);

}

Answer:

I hate U

Explanation:

For floating point numbers (float, double, long double) the values cannot be predicted exactly. Depending on the number of bytes, the precession