001package clone.factory.main; 002import clone.factory.A; 003class B extends A implements Cloneable { 004 public Object clone() throws CloneNotSupportedException { 005 return super.clone(); 006 } 007} 008public class Main { 009 public static void main(String[] args) throws CloneNotSupportedException { 010 B x = new B(); 011 A y = (A) x.clone(); 012 B z = (B) x.clone(); 013 } 014}