gs gs111 Class Components (Using Java) - Copy Constructors - Quiz No.2
gs gs111 OOP Object Oriented Programming Java Quiz
This quiz belongs to book/course code gs gs111 OOP Object Oriented Programming Java of gs organization. We have 178 quizzes available related to the book/course OOP Object Oriented Programming Java. This quiz has a total of 5 multiple choice questions (MCQs) to prepare and belongs to topic Class Components (Using Java). NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
import java.util.*; public class Main { LinkedList l = new LinkedList(); Main(int i) { l.add(i); } Main(Main a) { l = (LinkedList) a.l.clone(); } public static void main(String[] args) { Main a = new Main(5); Main b = new Main(a); System.out.println(b.getClass()); System.out.println(a.getClass().getSuperclass()); } }
class Main class Object
class Main class java.io.Object
class Main class java.lang.Object
import java.util.*; public class Main { LinkedList l = new LinkedList(); Main(int i) { l.add(i); } Main(Main a) { l = (LinkedList) a.l.clone(); } void className() { System.out.println(l.getClass()); System.out.println(l.getClass().getSuperclass()); } public static void main(String[] args) { Main a = new Main(5); Main b = a; b.className(); } }
class java.lang.LinkedList class java.lang.AbstractSequentialList
class java.io.LinkedList class java.io.AbstractSequentialList
class java.util.LinkedList class java.util.AbstractSequentialList
import java.util.*; public class Main { LinkedList l = new LinkedList(); Main(int i) { l.add(i); } Main(Main a) { l = (LinkedList) a.l.clone(); } void push(int a) { l.add(a); } void print() { System.out.println(l); } public static void main(String[] args) { Main a = new Main(5); Main b = new Main(a); a.push(10); a.push(20); b.push(30); b.push(40); b.print(); a.print(); } }
{30, 40} {5, 10, 20}
{5, 30, 40} {5, 10, 20}
[30, 40] [5, 10, 20]
[5, 30, 40] [5, 10, 20]