gs gs111 Inheritance (Using Java) - Single Level Inheritance - 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 Inheritance (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.
class A { void print() { System.out.println("A"); } } class B extends A { void print() { System.out.println("B"); } } public class Single { public static void main(String[] args) { A b = new B(); b.print(); } }
class A { void print() { System.out.println("A"); } } class B extends A { void print() { System.out.println("B"); } } public class Single1 { public static void main(String[] args) { A a = new A(); a.print(); } }
class Base { String s = "NVAEducation"; } class Derived extends Base { void index() { System.out.println(s.indexOf('N')); } } public class Index { public static void main(String[] args) { Derived a = new Derived(); a.index(); } }
$ javac Index.java $ java Index -1
class Base { char ch = 'D'; } class Derived extends Base { void ascii() { System.out.println((int)ch); } } public class Ascii { public static void main(String[] args) { Derived a = new Derived(); a.ascii(); } }
class Base { int a = 76; } class Derived extends Base { void ascii() { System.out.println((char)a); } } public class Ascii1 { public static void main(String[] args) { Derived i = new Derived(); i.ascii(); } }
class Base { int a[] = {1,2,3,4,5,6}; } class Derived extends Base { void even() { for(int i = 0; i < a.length; i++) { if(i%2==0) { System.out.print(a[i]+" "); } } } } public class Array { public static void main(String[] args) { Derived a = new Derived(); a.even(); } }
class Base { int x = 30; } class Derived extends Base { int y = 45; void display() { System.out.println(this); } } public class ClassName { public static void main(String[] args) { Derived a = new Derived(); a.display(); } }