gs gs111 Class Components (Using Java) - Assigning Objects - 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 { int a, b; Main(int i, int j) { a = i; b = j; } public static void main(String[] args) { Main a = new Main(27, 2); Main b = a; System.out.println(a.a); System.out.println(b.b); } }
27 2 2 27 public class Main { int a, b; Main(int a, int b) { this.a = a; this.b = b; } void Print() { System.out.println(this); } public static void main(String[] args) { Main x = new Main(20, 40); Main y = x; y.Print(); } }
20 40 public class Main { int a, b; Main(int a, int b) { this.a = a; this.b = b; } public static void main(String[] args) { Main x = new Main(40, 80); Main y = x; System.out.println(x); System.out.println(y); } }
Main@2a139a55 Main@4a210c21Main@2a139a55 Main@2a139a5520 40 20 40 import java.util.*; public class Main { int a; Main(int i) { a = i; } public static void main(String[] args) { Main a = new Main(20); Main b = a; System.out.println(b.getClass()); System.out.println(a.getClass().getSuperclass()); } }
class Main class Objectclass Main class java.io.Objectclass Main class java.lang.Object import java.util.*; public class Main { LinkedList l = new LinkedList(); Main(int i) { l.add(i); } 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 = a; a.push(40); b.push(30); b.push(40); b.print(); a.print(); } }
[5, 40, 30, 40] [5, 40, 30, 40][5, 40] [30, 40][5, 40] [5, 30, 40]