Java Questions

Q:

Which of the following are valied?

A) A class can extend any number of classes simulteneously B) A class can implement only one interface at a time
C) A class can extend other class or can implement interface but not both simulteneously D) None of the above
 
Answer & Explanation Answer: D) None of the above

Explanation:

A is wrong because a class can extend nly one class .B is wrong because a class can implement any number of interfaces.C is wronb because both can can be done simulteneously.So, D is correct

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

1 3576
Q:

When is the finalize() called ? What is the purpose of finalization ?

Answer

The finalize method is called by the garbage collector, just before releasing the object’s memory. It is normally advised to release resources held by the object inside the finalize method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 3443
Q:

What do you know about the big-O notation and can you give some examples with respect to different data structures ?

Answer

The Big-O notation simply describes how well an algorithm scales or performs in the worst case scenario as the number of elements in a data structure increases. The Big-O notation can also be used to describe other behavior such as memory consumption. Since the collection classes are actually data structures, we usually use the Big-O notation to chose the best implementation to use, based on time, memory and performance. Big-O notation can give a good indication about performance for large amounts of data.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 3384
Q:

Why static methods cannot access non static variables or methods?

Answer

A static method cannot access non static variables or methods because static methods doesnt need the object to be accessed. So if a static method has non static variables or non static methods which has instantiated variables they will no be intialized since the object is not created and this could result in an error.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

9 3312
Q:

Can a main() method be declared final?

Answer Yes. Any inheriting class will not be able to have it's own default main() method.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 3239
Q:

What do you mean by platform independence?

Answer

Platform independence means that we can write and compile the java code in one platform (Eg Windows) and can execute the class in any other supported platform (Eg Linux,Solaris,etc).

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 3218
Q:

There is one default constructor in every class.

A) The above statement is true B) The above statement is false
C) Both true and false D) None
 
Answer & Explanation Answer: A) The above statement is true

Explanation:

There will always be a default constructor in every class 

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 3148
Q:

What is difference between Path and Classpath?

Answer

PATH and CLASSPATH are operating system level environment variables. PATH is used to define where the system can find the executables (.exe) files whereas CLASSPATH is used to specify the location of .class files.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 3103