Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:43:54+00:00 2026-06-07T16:43:54+00:00

As per java.lang.Cloneable interface: The documentation for the Cloneable says – Note that this

  • 0

As per java.lang.Cloneable interface:

The documentation for the Cloneable says –

Note that this interface does not contain the clone method. Therefore, it is not possible to clone an object merely by virtue of the fact that it implements this interface. Even if the clone method is invoked reflectively, there is no guarantee that it will succeed.

But the following code is working correctly. It is not giving any error when I call ex1.clone.

package com.sriPushpa.thread;

public class exceptionHandling implements Cloneable {
    int a = 10;

    public static void main(String args[]) {
        exceptionHandling ex1 = new exceptionHandling();
        exceptionHandling ex2 = null;
        try {
            ex2 = (exceptionHandling) ex1.clone();

        } catch (CloneNotSupportedException e) {

            e.printStackTrace();
        }
        System.out.println("SUCCESS");
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:43:56+00:00Added an answer on June 7, 2026 at 4:43 pm

    The clone() method is implemented by java.lang.Object, as a protected method. Your code works because you’re calling the clone() method from the same class as the one you clone.

    If you want your object to be cloneable, you should override the clone() method and make it public:

    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
    

    Note that the doc doesn’t say that implementing the Cloneable interface will always make clone() fail. It says that implementing it is not a guarantee that clone() will work. This is very different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As per Java web start where does the jar file get downloaded on a
Using AmazonSimpleEmailServiceClient.sendEmail() ; as per java docs All service calls made using this client
I was reading the JavaDoc for Threadlocal here https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/ThreadLocal.html and it says ThreadLocal instances
Per the Java documentation, the hash code for a String object is computed as:
As per Java API spec, the signature of Collections.reverseOrder is public static <T> Comparator<T>
As per the java docs, invoking close() on any java.io Streams automatically invokes flush().
I'm converting a Java server application which used blocking IO and thread-per-client to NIO
Switching from JVM 1.4 to 1.5 has performance benefits as per release notes. http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#performance
Per a client's request I have written a communication class that inherits from webclient.
Per this question (see comments near the bottom), I was wondering if anyone knows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.