Program to implement the Multiple Inheritance (Exam Interface, Student & Result classes)
Interface looks like class but it is not a class. An interface can have methods and variables just like the class but the methods declared in interface are by default abstract (only method signature, no body). Also, the variables declared in an interface are public, static & final by default. The interface in java is a mechanism to achieve fully abstraction.
The class that implements interface must implement all the methods of that interface. Also, java programming language does not support multiple inheritance, using interfaces we can achieve this as a class can implement more than one interfaces. It cannot be instantiated just like abstract class. To achieve multiple inheritance in Java you have to use interface. The syntax for declaring interface is given below:
interface <interface-name> {
// variable declarations
// Method declarations (no implementation)
}
The implements keyword is used to for implementing interface and extends keyword is used to extend the class. The syntax for extending class and implementing interface is:
class <subclass-name> extends <superclass-name> implements <interface-name> {
// Body of subclass
}
In this program, we have achieved multiple inheritance using interface. We have created an interface Exam which has one method Percent_cal( ) without implementation (body). Then we declare the class Student having data members name, roll_no, marks1, marks2 and method show( ). In class Result we have extended Student class and implemented interface Exam interface as shown in program.
PROGRAM
/* Program to implement the Multiple Inheritance */
interface Exam {
void Percent_cal();
}
class Student {
String name;
int roll_no, Marks1, Marks2;
Student(String n, int rn, int m1, int m2) {
name = n;
roll_no = rn;
Marks1 = m1;
Marks2 = m2;
}
void show() {
System.out.println("Student Name : "+name);
System.out.println("Roll no : "+roll_no);
System.out.println("Marks1 : "+Marks1);
System.out.println("Marks2 : "+Marks2);
}
}
class Result extends Student implements Exam {
float per;
Result(String n,int rn,int m1,int m2) {
super(n,rn,m1,m2);
}
public void Percent_cal() {
int tot = Marks1 + Marks2;
per = (float)tot / 2;
}
void display() {
show();
System.out.println("Percentage = "+per);
}
}
public class StudentDetails {
public static void main (String[] args) {
Result r = new Result("Aashish",11,75,95);
r.Percent_cal();
r.display();
}
}
OUTPUT
C:\>javac StudentDetails.java C:\>java StudentDetails Student Name : Aashish Roll no : 11 Marks1 : 75 Marks2 : 95 Percentage = 85.0
I really like this post and found such a good information on your blog. I also visit many blogs for information but this one I got the correct information.
ReplyDeleteRegards,
Java Online Training | Java Online Training in India | Java Online Training India | Java Online Training in Hyderabad | Java Online Training Hyderabad | Java Training in Hyderabad | Java Training in India | Java Training Institutes in India | Java Training Institutes in Hyderabad | Java Course in Hyderabad | Java Training | Learn Java Online | Online Java Training | Best Java online Training Institutes in Hyderabad | Best Java Training Institutes in Hyderabad | Best Institutes for Java | Java Institutes in Hyderabad | Best Institutes for Java in Hyderabad | Learn Java | Java Training Institutes in Hyderabad | Java Certification | Java Certification Training | Java Certification Training in Hyderabad | Java Certification Training in India
Thank you..
DeleteThanks for sharing this information. Interface in Java .
ReplyDeleteThe effectiveness of IEEE Project Domains depends very much on the situation in which they are applied. In order to further improve IEEE Final Year Project Domains practices we need to explicitly describe and utilise our knowledge about software domains of software engineering Final Year Project Domains for CSE technologies. This paper suggests a modelling formalism for supporting systematic reuse of software engineering technologies during planning of software projects and improvement programmes in Project Centers in Chennai for CSE.
DeleteSoftware management seeks for decision support to identify technologies like JavaScript that meet best the goals and characteristics of a software project or improvement programme. JavaScript Training in Chennai Accessible experiences and repositories that effectively guide that technology selection are still lacking.
Aim of technology domain analysis is to describe the class of context situations (e.g., kinds of JavaScript software projects) in which a software engineering technology JavaScript Training in Chennai can be applied successfully
Great post I would like to thank you for the efforts you have made in writing this interesting and knowledgeable article.
ReplyDeleteDissertation Examples
very informative one and i really impressded. best job training in chennai
ReplyDeletevery interesting article and informative one. i can learn more about java. best java training in chennai
ReplyDeleteIf you want to learn advance Java programming so connect with BR Brains Java training institute in Jaipur, which provide best advance java training course.
ReplyDeletea large number of the present understudies getting through the lawyer's exam are experiencing issues following the call of a paper question; they are not recognizing an UNIVERSITY IN KENYA
ReplyDeleteadequate number of issues in the reality designs; they are experiencing difficulty applying the law to the certainties and breaking down them; and their punctuation and spelling isn't satisfactory.
Today, most clients have able customer machines which can do considerably more than HTML permits. what is programming language
ReplyDeleteHaving Insufficient Material: Nothing aggravates a book advertiser more than endeavoring to advance a book that isn't promotable. What makes a book unfit to be advanced? amryl
ReplyDeletehigh-quality web site, where did u come happening taking into consideration the mention coarsely this posting?i've addiction in a number of the articles almost about the order of your website now, and i in reality in imitation of your fashion. thanks 1,000,000 and engross keep going on the functioning discharge loyalty. BA 2nd Year Results
ReplyDeleteThank you for sharing this post.
ReplyDeleteJava Training Institutes in Munirka
In your blog I was happy to see your article, better than last time, and have made great progress, good samaritan school jasola I am very pleased. I am looking forward to your article will become better and better.
ReplyDeleteNative apps do not need internet connectivity to function this gives users anytime, anywhere access.
ReplyDeletemobile app development london
nice information about Java Programming
ReplyDeleteVery efficiently written information. BCom 1st Year Result It will be beneficial to anybody who utilizes it, including me. Keep up the good work. BCom 2nd Year Result For sure i will check out more posts. This site seems to get a good amount of visitors.BCom 3rd Year Result
ReplyDeleteThank you for this! this is very helpful. I'm impressed with your blo...
ReplyDeleteBA 2 YEAR REVALUATION RESULT
This is a great post. BA 1st Year Result I like this topic.This site has lots of advantage. BA 2nd Year Result I found many interesting things from this site. It helps me in many ways.Thanks for posting
ReplyDeletethis again. BA 3rd Year Result
we will inform you once after announcement...
ReplyDeleteDevi Ahilya University exam
DAVV 1st, 3rd, 5th Semester Exam
DAVV Result
I just want to let you know that I just check out your site and I find it very interesting and informative...
ReplyDeleteBA 1 YEAR RECHECKING RESULT
BA 1 YEAR REVAL RESULT
BA 1 YEAR REVALUATION RESULT
BA 1ST YEAR RECHECKING RESULT
BA 1ST YEAR REVAL RESULT
BA 1ST YEAR REVALUATION RESULT
BA FIRST YEAR RECHECKING RESULT
BA FIRST YEAR REVAL RESULT
BA FIRST YEAR REVALUATION RESULT
BA PART 1 RECHECKING RESULT
BA PART 1 REVALUATION RESULT
This is a great inspiring article.I am pretty much pleased with your work.You can really really helpful information. Keep it up. Keep blogging. Looking to your next post.
ReplyDeletebest dissertation writing service
There are lots of dissertation internet websites on-line since you attain web famous from the site. web services testing
ReplyDeleteWrite a program to display student CMS, marks in three subjects and total marks. Consider class student stores the roll no, class test, stores marks of three subjects class result contains total marks obtained in test. The class result can inherit the details of the
ReplyDeletemark obtained in test and roll no of a student through multilevel inheritance.
Your post is very great.i read this post this is a very helpful. i will definitely go ahead and take advantage of this. You absolutely have wonderful stories.Cheers for sharing with us your blog. python training in noida
ReplyDeleteGreat articles and great layout. Your blog post deserves all of the positive feedback it’s been getting. 50 free instagram likes instantly
ReplyDeleteI am definitely enjoying your website. You definitely have some great insight and great stories.
ReplyDeleteWrite My Assignments For Me
Blog was useful and informative.
ReplyDeleteJava Training Institute in Chennai
Python Classes in Chennai
A very delightful article that you have shared here. Your blog is a valuable and engaging article for us, and also I will share it with my companions who need this info. Thankful to you for sharing an article like this.Aws Training in Delhi
ReplyDeleteYour post is really good thanks for sharing these kind of post but if anyone looking for Best Consulting Firm for Fake Experience Certificate Providers in hyderabad, India with Complete Documents So Dreamsoft Consultancy is the Best Place.Further Details Here- 9599119376 or VisitWebsite-https://experiencecertificates.com/experience-certificate-provider-in-Hyderabad.html
ReplyDeleteI really liked while reading your article, the information you have mentioned in this post is really good. I am waiting for your upcoming post your ,post is really good . Otherwise if anyone want to Learn javaCourse So Contact Us-9311002620 Or check my website- https://www.htsindia.com/Courses/tally/tally-training-course
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteSAP BI Course in Delhi
ReplyDeleteHave to work? need of money but have no experience certificate. Get in touch with us we provide experience certificate in Gurgaon 100% genuine certificate in Gurgaon. It will help it your courier. So don’t be late. Get your experience letter now. For experience letter in Delhi contact at 9599119376 or can visit our website at https://experiencecertificates.com/experience-certificate-provider-in-Gurgaon.html
ReplyDeleteNice Blog, it is very Impressive. keep sharing good information with us.
ReplyDeleteLearn Java Online
JAVA Course in Chennai
Java Course in Bangalore