Showing posts with label JAVA CODE SNIPPET-1. Show all posts
Showing posts with label JAVA CODE SNIPPET-1. Show all posts

JAVA CODE SNIPPET-1

Java Code Snippet-1
package techyield;

public class GrandParent {
 public void method1(int a){
  System.out.println("In GrandParent class and in method1 
and with one int argument and value is "+a);
 }
}
package techyield;

public class Parent extends GrandParent{
 public void method1(int a){
  System.out.println("In Parent class and in method1 and 
with one int argument and value is "+a);
 }
}
package techyield;

public class Child extends Parent{

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  System.out.println("Main method");
  Child child=new Child();
  child.method1(2);

 }
 public void method1(int a){
  System.out.println("In child class and in method1 and 
with one int argument and value is "+a);
 }
}
What is the Output On the Console ?

Select an answer

Please comment below if you have any doubts.

Featured Post

H1B Visa Stamping at US Consulate

  H1B Visa Stamping at US Consulate If you are outside of the US, you need to apply for US Visa at a US Consulate or a US Embassy and get H1...