0
Q:

Which of the following statements are equal for a variable declared in the interface ?

1. int X=10
2. public int X=10
3. public static final int X=10

A) Only 1 and 2 are equal B) Only 2 and 3 are equal
C) All are unequal D) All are equal

Answer:   D) All are equal



Explanation:

All the statements are equal because inside an interface a variable declared will be public static final by default 

Subject: Java
Job Role: IT Trainer
Q:

What is the security mechanism used in java?

Answer

Java uses sand box security model.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1444
Q:

What is diamond problem?

Answer

The diamond problem is an ambiguity that can occur when a class multiply inherits from two classes that both descend from a common super class

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1736
Q:

What is the difference between array and ArrayList ?

Answer

Array is collection of same data type. Array size is fixed, It cannot be expanded.


 


But ArrayList is a growable collection of objects.ArrayList is a part of Collections Framework and can work with only objects.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1436
Q:

How will you define an abstract class?

Answer

An abstract class is defined with the keyword abstract Eg:
public abstract class MyClass { }

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1340
Q:

What is an abstract class?

Answer

An abstract class is an incomplete class. An abstract class is defined with the keyword abstract . We cannot create an object of the abstract class because it is not complete. It sets a behavioral protocol for all its child classes.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1620
Q:

What is the difference between a constructor and a method?

Answer

A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator. We cannot invoke a constructor directly.


 


A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1823
Q:

What is a class, member and local variable?

Answer

Variables declared within a method are local variables. Variables declared within the class are member variables.  Variables declared within the class with static modifier are class variables 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1350
Q:

What is polymorphism?

Answer

It is the ability of an object to behave differently on different situations for the same message.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1559