gs gs111 Class Components (Using Java) - Copy Constructors - Quiz No.1
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 10 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.
public class Main { String s; Main(String s) { this.s = s; } Main(Main a) { s = a.s; } void Print() { System.out.println(s); } public static void main(String[] args) { Main a = new Main("NVAEducation"); Main b = new Main(a); b.Print(); } }
public class Main { String s; Main(String s) { this.s = s; } Main(Main a) { s = a.s; } void print() { System.out.println(this); } public static void main(String[] args) { Main a = new Main("Copy Constructor"); Main b = new Main(a); a.print(); b.print(); } }
Copy Constructor Copy Constructor
Main@2a139a55 Main@15db9742
Main@15db9742 Main@15db9742
public class Main { String s; Main(String s) { this.s = s; } void print() { System.out.println(this); } public static void main(String[] args) { Main a = new Main("Copy Constructor"); Main b = a; a.print(); b.print(); } }
Copy Constructor Copy Constructor
Main@2a139a55 Main@2a139a55
Main@2a139a55 Main@15db9742
public class Main { int a; Main(int a) { this.a = a; } Main(Main s) { a = s.a; } void set() { a = 40; } void display() { System.out.println(a); } public static void main(String[] args) { Main a = new Main(10); Main b = new Main(a); Main c = a; a.display(); a.set(); b.display(); c.display(); } }
10 10 10
10 40 40
10 10 40
public class Main { char s; Main(char s) { this.s = s; } Main(Main a) { s = 's'; } void Char() { System.out.println((int)s); } public static void main(String[] args) { Main a = new Main('S'); Main b = new Main(a); a.Char(); b.Char(); } }
83 83
115 83
83 115