Showing posts with label inheritance in java. Show all posts
Showing posts with label inheritance in java. Show all posts

Tuesday, May 9, 2017

Student Information Using Inheritance in Java

Here is a very simple program that I wrote using Java as my programming language that demonstrate how to use inheritance. The program will display student information on the screen. I hope you will learn something out of it.  Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

package demo;


class Student {
String name="Mario Chua";
String course="Bachelor of Science in Business Management";
int age=17;
}

public class inheritance extends Student {
String school="Manila State University";
double tuition= 45600.51;

public static void main(String[] args) {
inheritance studs = new inheritance();
System.out.println();
        System.out.println("Student Information Using Inheritance in Java");
        System.out.println();
System.out.println("Student Name : " + studs.name);
System.out.println("Course       : " + studs.course);
System.out.println("Age          : " + studs.age);
System.out.println("School       : " + studs.school);
System.out.println("Tuition Fee  : Php " + studs.tuition);
}

}






Saturday, June 25, 2016

Simple Inheritance in Java

A simple program that I wrote in Java to show how the concepts of inheritances works. This program will greet the user three times when we assign a name of the user in a string. The code is very easy to understand and learn ideal for those that are new in Java programming.

 Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

Simple_Inheritance.java


package hello;


class hello_world{ 

 public void greet2(String user){
        System.out.println("Hello " + user + " How are you?");
        System.out.println();
  }
 public void greet3(String user){
        System.out.println("Kamusta ka " + user + " Welcome to Philippines.");
        System.out.println();
        System.out.println("\t End of Program");
     }
 
}


public class Simple_Inheritance extends hello_world {
 public void greet1(String person1){
    System.out.println("\t Simple Inheritance in Java");
    System.out.println();
        System.out.println("Welcome " + person1 + " to our home.");
        System.out.println();
  }
 public static void main(String args[]){
 String name="Jake R. Pomperada";
 
 Simple_Inheritance person = new Simple_Inheritance();
 person.greet1(name);
 person.greet2(name);
 person.greet3(name);
 
  }
}