Java Questions

Q:

Why is the main() method declared static?

Answer

main() method is called by the JVM even before the instantiation of the class, hence it is declared as static.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2173
Q:

I do not want my class to be inherited by any other class. What should i do?

Answer You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2162
Q:

What are pass by reference and pass by value ?

Answer

When an object is passed by value, this means that a copy of the object is passed. Thus, even if changes are made to that object, it doesn’t affect the original value. 


When an object is passed by reference, this means that the actual object is not passed, rather a reference of the object is passed. Thus, any changes made by the external method, are also reflected in all places.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2145
Q:

What is inheritance?

Answer

Inheritance is the ability to create new classes based on existing classes. It is useful to reuse existing code.

Report Error

View answer Workspace Report Error Discuss

0 2139
Q:

What is the argument of main() method?

Answer main() method accepts an array of String object as arguement.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2137
Q:

What is MultiTasking?

Answer

Executing more than one program simultaniously.(i.e at time)


Ex:


Windows media player  is a program


Internet explorer(IE) is another program executing both the programs  at a time is called multi tasking.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2103
Q:

What are instance variables?

Answer Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2100
Q:

Warning implicit declaration of function?

Answer

Function: A Function is a block of statement which perform some operation.



Declaring the function before using the function in program is known as implicit declaration of the function.



For Example::


int bar(void); // function (forward) declaration



int main(void) {


bar(); // bar was declared, the compiler has all the info


return foo(123); // foo not yet known; impl. decl. warning


}



// not previously declared function definition


int foo(int a) {


return a;



// previously declared function definition


int bar() {


return 321;


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: IT Trainer , Analyst

1 2085