SlideShare a Scribd company logo
//Ques. 10 WAP to implement inheritance and overloading methods.

importjava.util.*;
class mob
{
privateint roll;
private String name;
Scanner x=new Scanner(System.in);
public void getmob( )
{
System.out.print("n Enter Roll No. = ");
roll=x.nextInt( );
System.out.print("n Enter Name = ");
name=x.next( );
}
public void putmob( )
{
System.out.println("n Roll No. : "+roll);
System.out.println("n Name: "+name);
}
}
class drive extends mob
{
publicintp,c,m;
voidgetdrive( )
{
getmob( );
Scanner in=new Scanner(System.in);
System.out.print("n Marks in Physics: ");
p=in.nextInt( );
System.out.print(" Marks in Chemistry: ");
c=in.nextInt( );
System.out.print(" Marks in Maths: ");
m=in.nextInt( );
}
public void putdrive( )
{
putmob( );
System.out.println("n Marks: "+p+", "+c+", "+m);
}
}
class pen extends drive
{
privateint tm;
voidgetresult( )
{
getdrive( );
tm=p+c+m;
}
voidputresult( )
{
putdrive( );
System.out.println(" Total Marks: "+tm);
}
}
class computer
{
public static void main(String arg[ ])
{
pen s=new pen( );
s.getresult( );
s.putresult( );
}
}

OUTPUT:-

More Related Content

DOCX
Overriding abstract in java
PDF
Reactive x
PDF
When RV Meets CEP (RV 2016 Tutorial)
PDF
Activity Recognition Through Complex Event Processing: First Findings
PDF
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
ODP
PDF
JavaSE7 Launch Event: Java7xGroovy
PPT
Tilting Google Maps and MissileLauncher
Overriding abstract in java
Reactive x
When RV Meets CEP (RV 2016 Tutorial)
Activity Recognition Through Complex Event Processing: First Findings
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
JavaSE7 Launch Event: Java7xGroovy
Tilting Google Maps and MissileLauncher

What's hot (20)

PPTX
Lrz kurse: r as superglue
PDF
C c++-meetup-1nov2017-autofdo
PPTX
Javascript Basics for Advertisers
PDF
Modern c++ Memory Management
PDF
Rcpp11 genentech
DOCX
Constructor Overloading in java
PPTX
Oops in c++
PDF
Rcpp11 useR2014
PDF
Session 9 4 alp to display the current system time using dos int 21 h
PPTX
Azure Durable Funkiness - .NET Oxford June 2018
PPTX
เมธอด กลุ่ม3
DOCX
Circular queue
PDF
R/C++ talk at earl 2014
PDF
software-vulnerability-detectionPresentation
PDF
Debugging JavaScript with Chrome
DOCX
timingExercise
ODP
Dynamic Tracing of your AMP web site
PDF
Sujet bac info 2013 g1, g2 et g3 avec correction
PPTX
Python queue solution with asyncio and kafka
DOC
VLSI Sequential Circuits II
Lrz kurse: r as superglue
C c++-meetup-1nov2017-autofdo
Javascript Basics for Advertisers
Modern c++ Memory Management
Rcpp11 genentech
Constructor Overloading in java
Oops in c++
Rcpp11 useR2014
Session 9 4 alp to display the current system time using dos int 21 h
Azure Durable Funkiness - .NET Oxford June 2018
เมธอด กลุ่ม3
Circular queue
R/C++ talk at earl 2014
software-vulnerability-detectionPresentation
Debugging JavaScript with Chrome
timingExercise
Dynamic Tracing of your AMP web site
Sujet bac info 2013 g1, g2 et g3 avec correction
Python queue solution with asyncio and kafka
VLSI Sequential Circuits II
Ad

Viewers also liked (6)

PDF
An Illumination Invariant Face Recognition by Selection of DCT Coefficients
PPTX
Face Recognition
PDF
Robust Face Recognition under Varying Illumination and Occlusion Considering ...
PPT
Facial Recognition Vinod
PPT
Automated Face Detection and Recognition
PPTX
FACE RECOGNITION ACROSS NON-UNIFORM MOTION BLUR
An Illumination Invariant Face Recognition by Selection of DCT Coefficients
Face Recognition
Robust Face Recognition under Varying Illumination and Occlusion Considering ...
Facial Recognition Vinod
Automated Face Detection and Recognition
FACE RECOGNITION ACROSS NON-UNIFORM MOTION BLUR
Ad

Similar to WAP to implement inheritance and overloading methods in java (20)

DOCX
PDF
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
DOCX
Java file
DOCX
Java file
DOCX
Java Programs Lab File
DOCX
WAP to add two given matrices in Java
DOCX
Java Practical1 based on Basic assignment
PDF
Java doc Pr ITM2
DOCX
import java.uti-WPS Office.docx
PDF
Java programming lab manual
DOCX
import java-util--- import java-io--- class Vertex { -- Constructo.docx
PDF
9)Answerimport java.util.; import java.lang.; import java.pdf
PDF
Hi,I have updated your code. It is working fine now. Highllighted .pdf
PDF
Simple 27 Java Program on basic java syntax
PDF
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
PDF
CountStringCharacters.javaimport java.util.Scanner; public cla.pdf
PDF
Review Questions for Exam 10182016 1. public class .pdf
DOCX
Wap to implement bitwise operators
PDF
CODEimport java.util.; public class test { public static voi.pdf
PROGRAMING IN JAVA 4TH SEM DIGVIJAY COLLAGE
Java file
Java file
Java Programs Lab File
WAP to add two given matrices in Java
Java Practical1 based on Basic assignment
Java doc Pr ITM2
import java.uti-WPS Office.docx
Java programming lab manual
import java-util--- import java-io--- class Vertex { -- Constructo.docx
9)Answerimport java.util.; import java.lang.; import java.pdf
Hi,I have updated your code. It is working fine now. Highllighted .pdf
Simple 27 Java Program on basic java syntax
Repeat Programming Project 2 in Chapter 5. This time, add the follow.pdf
CountStringCharacters.javaimport java.util.Scanner; public cla.pdf
Review Questions for Exam 10182016 1. public class .pdf
Wap to implement bitwise operators
CODEimport java.util.; public class test { public static voi.pdf

More from One97 Communications Limited (20)

DOCX
Er. Model Of Hospital Management
DOCX
Fcfs Cpu Scheduling With Gantt Chart
PPTX
Neural Interfacing
PPT
Blue eye technology
PPTX
Computer Forensics
PPTX
Protect Folders without using any Software
PPTX
Introduction to Java Programming
DOCX
WAP to invoke constructors using super keyword in java
DOCX
WAP to find out whether the number is prime or not in java
DOCX
How to achieve multiple inheritances by using interface in java
DOCX
Method overriding in java
DOCX
program on Function overloading in java
DOCX
Program on usage of Final keyword in java
DOCX
WAP to initialize different objects with different values in java
DOCX
Conversion of data types in java
Er. Model Of Hospital Management
Fcfs Cpu Scheduling With Gantt Chart
Neural Interfacing
Blue eye technology
Computer Forensics
Protect Folders without using any Software
Introduction to Java Programming
WAP to invoke constructors using super keyword in java
WAP to find out whether the number is prime or not in java
How to achieve multiple inheritances by using interface in java
Method overriding in java
program on Function overloading in java
Program on usage of Final keyword in java
WAP to initialize different objects with different values in java
Conversion of data types in java

Recently uploaded (20)

PPTX
Lesson notes of climatology university.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Pre independence Education in Inndia.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
RMMM.pdf make it easy to upload and study
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
master seminar digital applications in india
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Cell Types and Its function , kingdom of life
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
Lesson notes of climatology university.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Pre independence Education in Inndia.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
RMMM.pdf make it easy to upload and study
human mycosis Human fungal infections are called human mycosis..pptx
Microbial disease of the cardiovascular and lymphatic systems
master seminar digital applications in india
Complications of Minimal Access Surgery at WLH
Cell Types and Its function , kingdom of life
Microbial diseases, their pathogenesis and prophylaxis
2.FourierTransform-ShortQuestionswithAnswers.pdf
Basic Mud Logging Guide for educational purpose
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Abdominal Access Techniques with Prof. Dr. R K Mishra
TR - Agricultural Crops Production NC III.pdf
Final Presentation General Medicine 03-08-2024.pptx

WAP to implement inheritance and overloading methods in java

  • 1. //Ques. 10 WAP to implement inheritance and overloading methods. importjava.util.*; class mob { privateint roll; private String name; Scanner x=new Scanner(System.in); public void getmob( ) { System.out.print("n Enter Roll No. = "); roll=x.nextInt( ); System.out.print("n Enter Name = "); name=x.next( ); } public void putmob( ) { System.out.println("n Roll No. : "+roll); System.out.println("n Name: "+name); } } class drive extends mob { publicintp,c,m; voidgetdrive( ) {
  • 2. getmob( ); Scanner in=new Scanner(System.in); System.out.print("n Marks in Physics: "); p=in.nextInt( ); System.out.print(" Marks in Chemistry: "); c=in.nextInt( ); System.out.print(" Marks in Maths: "); m=in.nextInt( ); } public void putdrive( ) { putmob( ); System.out.println("n Marks: "+p+", "+c+", "+m); } } class pen extends drive { privateint tm; voidgetresult( ) { getdrive( ); tm=p+c+m; } voidputresult( ) { putdrive( );
  • 3. System.out.println(" Total Marks: "+tm); } } class computer { public static void main(String arg[ ]) { pen s=new pen( ); s.getresult( ); s.putresult( ); } } OUTPUT:-