Searching for "%"

Q:

How to define a constant variable in Java?

Answer The variable should be declared as static and final. So only one copy of the variable exists for all instances of the class and the value can't be changed also.
static final int PI = 2.14; is an example for constant.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

Should a main() method be compulsorily declared in all java classes?

Answer No not required. main() method should be defined only if the source class is a java application.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

What is the return type of the main() method?

Answer Main() method doesn't return anything hence declared void.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

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

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

Q:

Is Java a pure object oriented language?

Answer

Java uses primitive data types and hence is not a pure object oriented language.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

Are arrays primitive data types?

Answer In Java, Arrays are objects.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

Does Java support multiple inheritance?

Answer Java doesn't support multiple inheritance.
Report Error

View answer Workspace Report Error Discuss

Subject: Java