Searching for "overriding"

Q:

Does not overriding hashcode() method has any performance implication ?

Answer

A poor Hashcode() function will result in frequent collision in HashMap which eventually increase time for adding an object into Hash Map.

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: Analyst , IT Trainer

Q:

why overriding finalize() method?

Answer

If constructor opens the file 


finalize() method closes that file.


 


If constructor opens the connection 


finalize() method closes that connection.


 


To perform finalization operation we must overriding finalize method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

What is the purpose of overriding toString() method?

Answer

we can override tostring() method to return String representation of our object data

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

What is the use of overriding?

Answer

- By using method overriding a sub class can change the definition of super class method.


- By using overriding a sub class can modify the functionality of the super class.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

How can you prevent a class from overriding in C# and Visual Basic?

Answer

You can prevent a class from overriding in C# by using the sealed keyword; whereas, the NotInheritable keyword is used to prevent a class from overriding in Visual Basic.

Report Error

View answer Workspace Report Error Discuss

Subject: .NET

Q:

What is the difference between method overriding and overloading?

Answer

Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

What are the restrictions when overriding a method ?

Answer

Overridden methods must have the same name, argument list, and return type (i.e., they must have the exact signature of the method we are going to override, including return type.)


The overriding method cannot be less visible than the method it overrides( i.e., a public method cannot be override to private).


The overriding method may not throw any exceptions that may not be thrown by the overridden method

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

Explain Overriding Polymorphism.?

Answer

Overriding means changing behavior of methods of base class in derive class by overriding the base class methods. If class A is a base class with method ’calculate’ and class B inherits class A, thus derives method ’calculate’ of class A. The behavior of ’calculate’ in class B can be changed by overriding it.

Report Error

View answer Workspace Report Error Discuss

Subject: Java