From 123d82fdb7151f91baedb76b7ef55ad330f0007a Mon Sep 17 00:00:00 2001 From: dikshaguptarambilas <116101686+dikshaguptarambilas@users.noreply.github.com> Date: Sun, 30 Oct 2022 23:51:31 +0530 Subject: [PATCH] Create coded2 --- coded2 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 coded2 diff --git a/coded2 b/coded2 new file mode 100644 index 0000000..ebe462f --- /dev/null +++ b/coded2 @@ -0,0 +1,26 @@ +class Student18 implements Cloneable{ +int rollno; +String name; + +Student18(int rollno,String name){ +this.rollno=rollno; +this.name=name; +} + +public Object clone()throws CloneNotSupportedException{ +return super.clone(); +} + +public static void main(String args[]){ +try{ +Student18 s1=new Student18(101,"amit"); + +Student18 s2=(Student18)s1.clone(); + +System.out.println(s1.rollno+" "+s1.name); +System.out.println(s2.rollno+" "+s2.name); + +}catch(CloneNotSupportedException c){} + +} +}