gs gs111 Class Components (Using Java) - this Keyword - 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="ABC"; Main(String s) { this.s = s; } void print() { System.out.println(this.s); } public static void main(String[] args) { Main a = new Main("NVAEducation"); a.print(); } }
public class Main { String s; Main(String s) { this.s = s; } void print() { System.out.println(this.s); } public static void main(String[] args) { Main a = new Main("San"); Main b = new Main("foundry"); a.print(); b.print(); } }
San foundry
public class Main { String s; Main(String s) { this.s=s; } void className() { System.out.println(this.s.getClass()); System.out.println(this.s.getClass().getSuperclass()); } public static void main(String[] args) { Main a = new Main("this"); a.className(); } }
String Object
class java.io.String class java.io.Object
class java.lang.String class java.lang.Object
class java.util.String class java.util.Object
public class Main { static class A { void print() { System.out.println(this.getClass()); System.out.println(this.getClass().getSuperclass()); } } public static void main(String[] args) { Main.A a = new Main.A(); a.print(); } }
class A class Main
class Main$A class Main
class Main$A class java.lang.Object
public class Main { int a=10; static class A { int a=20; void display(int a) { System.out.println(this.a); System.out.println(a); } } public static void main(String[] args) { Main.A a = new Main.A(); a.display(30); } }
10 20
20 30
10 30