selenium hierarchy

package SpecialConcepts;
 
class SuperClass1 {
	public void super_print() {
		System.out.println("Super Print");
	}
 
	public void super_show() {
		System.out.println("Super Show");
	}
}
 
public class SubClass1 extends SuperClass1 {
 
	public void sub_print() {
		System.out.println("Sub Print");
	}
 
	public void sub_show() {
		System.out.println("Sub Show");
	}
	
	public static void main(String[] args) {
 
		/* Child class object up cast to super class reference. Using super class reference , sub class object can not use methods
		 of sub class despite of being object of that class. Up casting restricts access or visibility of methods downwards */
		SuperClass1 superClass1 = new SubClass1();
		superClass1.super_print();
		superClass1.super_show();
		
		/* To access sub class methods, super class reference needs to be downcast to sub class reference. Note here we can down cast
		to a up cast reference only. */
		SubClass1 subClass1 = (SubClass1)superClass1;
		subClass1.sub_print();
		subClass1.sub_show();
		
 
	}
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source