answersLogoWhite

0

What is cloneable interface?

Updated: 12/17/2022
User Avatar

Wiki User

14y ago

Best Answer

Cloneable is a TAGGED or MARKER interface

A class implements the Cloneable interface to indicate to the Object.clone() method that it is legal for that method to make a field-for-field copy of instances of that class.

The interface Cloneable declares no methods.

Attempts to clone instances that do not implement the Cloneable interface result in the exception CloneNotSupportedException being thrown.

You want to override clone() to make it public instead of protected. For example, public Object clone() throws CloneNotSupportedException {

return super.clone();

}

If all your clone() methods call super.clone(), as is recommended, then eventually it will get passed up the inheritance chain all the way to Object.clone() to do the actual cloning, which is why you want to implement the Cloneable interface, so Object.clone() will agree to do it.

If it does not get passed to Object.clone() eventually, then you do not need to implement Cloneable.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is cloneable interface?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is markable interface in java?

The Interface which doesn't have any declarations of methods are called the markable interface (or marker interface)They are named marker interfaces, because their only purpose is to mark special classes.Example:In the Java API there is the interface Cloneable. Since Object already has the method clone() the Cloneable Interface is empty and is only used to mark classes, which objects are allowed to clone.There are Three marker interfaces that are Serializable,Remote and Cloneable.


What difference LinkedList and ArrayList?

public class ArrayList public class LinkedList extends AbstractList extends AbstractSequentialList implements List, RandomAccess, Cloneable, Serializableimplements List, Cloneable, Serializable Resizable-array implementation of the List interface.Linked list implementation of the List interface Implements all optional list operations, and permits all elements, including null. Implements all optional list operations, and permits all elements (including null).


What are the types of network interface card?

Gigabit Ethernet interface Controller interface Serial interface Multilink Group interface MFR (Multilink Frame Relay bundle interface) Dialer interface Loopback interface Tunnel interface ATM interface


What interface is an interface that uses graphics as compared to a command-driven interface?

Graphical User Interface


What is a tagging interface type?

A tagging interface type in Java is an interface that has not defined methods such as the java.io.Serializable interface.


Does a corsa have an interface on non interface engine?

Does a Chrysler Sebring 2008 have an interface or non interface engine


Is Iterator a class or Interface?

Its an interface.


What is an interface that uses graphics as compared to a command-drive interface?

The interface you are looking for is called a GUI (Graphical User Interface). This interface is supported by all Microsoft Windows Operating System's.


Can interface implement the other interface?

No. An interface cannot implement another interface, it can only just extend it. Because, an interface cannot implement any method as it has no method body declarations.


What has the author Marcus Tonndorf written?

Marcus Tonndorf has written: 'An interface in an interface in an interface'


What interface is extended by AWT event listeners?

The AWTEventListener interface implements the EventListener interface.


When was We Interface created?

We Interface was created in 2004.