//Program for Method Overriding class Bank { int rate_of_interest() { return 0; } } class SBI extends Bank { //override int rate_of_interest() { return 8; } } class ICICI extends Bank { //override int rate_of_interest() { return 7; } } class AXIS extends Bank { //override int rate_of_interest() { return 9; } } public class Method_Overriding { public static void main(String soham[]) { SBI sbi = new SBI(); ICICI icici = new ICICI(); AXIS axis = new AXIS(); System.out.print("\nSBI Rate of Interest: " + sbi.rate_of_interest()); System.out.print("\nICICI Rate of Interest: " + icici.rate_of_interest()); System.out.print("\nAXIS Rate of Interest: " + axis.rate_of_interest()); System.out.println(); } }
Output![]()
//Program for Constructor Overloading class Cube { int length; int breadth; int height; Cube() //constructor 1 { length = 10; breadth = 10; height = 10; } Cube(int length, int breadth, int height) //constructor 2 { this.length = length; this.breadth = breadth; this.height = height; } public int get_volume() { return (length * breadth * height); } } public class Constructor_Demo { public static void main(String soham[]) throws Exception { Cube cube_obj1 = new Cube(); Cube cube_obj2 = new Cube(10, 20, 30); System.out.println("Volume of Cube1 is : " + cube_obj1.get_volume()); System.out.println("Volume of Cube1 is : " + cube_obj2.get_volume()); } }
Output![]()
//Program for Scanner Class import java.util.Scanner; public class Scanner_Demo { public static void main(String soham[]) throws Exception { Scanner sc = new Scanner(System.in); System.out.print("\nEnter your rollno: "); int rollno = sc.nextInt(); System.out.print("\nEnter your name: "); String name = sc.next(); System.out.print("\nEnter your fee: "); double fee = sc.nextDouble(); System.out.print("\nStudents Details Are: "); System.out.print("\nRoll no: "+rollno); System.out.print("\nName: "+name); System.out.print("\nFee: "+fee); System.out.println(); } }
Output![]()
Thank you so much for sharing this worth able content with us. The concept taken here will be useful for my future programs and i will surely implement them in my study. Keep blogging article like this.
ReplyDeletesoftware testing course in chennai
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info scanning
ReplyDelete