SlideShare a Scribd company logo
CS3135/CS2135
Object Oriented Programming (Java)
BSCS-3 / MCS-3
Lecture # 5
Inheritance
Dialog boxes
Parsing
INHERITANCE
• Inheritance is the reusability of predefined functionality.
• Existing class is called superclass (base class in C++)and new class is called subclass (derived class in C++).
• Inheritance is also called Specialization because subclass can modify the behavior of its superclass
appropriately to that subclass.
• Direct superclass is the superclass from which subclass explicitly inherits.
• Indirect superclass is any class above the direct superclass in class hierarchy.
• In Java, class hierarchy begins with class Object (in package java.lang), which every class in Java directly or
indirectly extends.
• Java supports only single inheritance, in which each class is derived from exactly one direct superclass. It
does not support multiple inheritance.
Instructor: Tanzila Kehkashan
2
INHERITANCE
A superclass’s
• Public members are accessible wherever the program has
reference to an object of that superclass or one of its superclass.
• Private members can be accessed directly only within the
superclass’s declaration.
• Protected members have an inheritance level of protection
between public and private access. They can be accessed by
members of superclass and subclass and other classes in same
package.
• A superclass’s private methods are hidden in its subclass and can
be accessed only through the public or protected methods inherited
from the superclass.
Relationship between superclass & subclass
• A subclass can invoke a constructor of its superclass by using the
keyword super followed by a set of parentheses containing the
superclass constructor arguments. This must appear as the first
statement in the subclass’s constructor body.
Example
public class person
{
}
public class student extends person
{
}
public class employee extends person
{
}
public class result extends student
{
}
Instructor: Tanzila Kehkashan
3
GUI Components
• GUI component is an object with which the user interacts via mouse, keyboard or
another form of input, such as voice recognition.
• These are sometimes called controls or widgets (window gadgets).
• Lightweight Vs. Heavyweight GUI components
• Swing Vs. AWT components
• There are two sets of Java GUI components:
• ‘java.awt’ package (Abstract Window Toolkit)
• ‘javax.swing’ package
Instructor: Tanzila Kehkashan
4
GUI Components -> Dialogue Boxes
• Simple GUI based I/O with JOptionPane
• import javax.swing.JOptionPane;
• Message dialog
• Input dialog
• Option dialog
• Confirm dialog
• Dialog Constants / message Type
• ERROR_MESSAGE
• INFORMATION_MESSAGE
• WARNING_MESSAGE
• QUESTION_MESSAGE
• PLAIN_MESSAGE
Instructor: Tanzila Kehkashan
5
JOptionPane Methods
• static void showMessageDialog(Component, Object)
• static void showMessageDialog(Component, Object, String, int)
• static void showMessageDialog(Component, Object, String, int, Icon)
• static int showOptionDialog(Component, Object, String, int, int, Icon, Object[], Object)
• static int showConfirmDialog(Component, Object)
• static int showConfirmDialog(Component, Object, String, int)
• static int showConfirmDialog(Component, Object, String, int, int)
• static int showConfirmDialog(Component, Object, String, int, int, Icon)
• static String showInputDialog(Object)
• static String showInputDialog(Component, Object)
• static String showInputDialog(Component, Object, String, int)
• static String showInputDialog(Component, Object, String, int, Icon, Object[], Object)
Instructor: Tanzila Kehkashan
6
GUI Components -> Option Type
• DEFAULT_OPTION
• YES_NO_OPTION
• YES_NO_CANCEL_OPTION
• OK_CANCEL_OPTION
Return Values
• YES_OPTION
• NO_OPTION
• CANCEL_OPTION
• OK_OPTION
• CLOSED_OPTION
GUI Components -> Dialogue Box Constants
Instructor: Tanzila Kehkashan
7
Parse methods convert strings to numeric data types. These are
• Byte.parseByte(String)
• Integer.parseInt(String)
• Short.parseShort(String)
• Long.parseLong(String)
• Float.parseFloat(String)
• Double.parseDouble(String)
String Parse
Instructor: Tanzila Kehkashan
8
Instructor: Tanzila Kehkashan
9
Instructor: Tanzila Kehkashan
10
Instructor: Tanzila Kehkashan
11

More Related Content

PPTX
Unit II Inheritance ,Interface and Packages.pptx
pranalisonawane8600
 
PPT
Packages and interfaces
vanithaRamasamy
 
PPTX
full defination of final opp.pptx
rayanbabur
 
PPTX
Unit3 packages & interfaces
Kalai Selvi
 
PPT
web program-Inheritance,pack&except in Java.ppt
mcjaya2024
 
PDF
Classes and Object Concept Object Oriented Programming in Java
gedeios
 
PPTX
Objects and classes in OO Programming concepts
researchveltech
 
PPTX
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
Unit II Inheritance ,Interface and Packages.pptx
pranalisonawane8600
 
Packages and interfaces
vanithaRamasamy
 
full defination of final opp.pptx
rayanbabur
 
Unit3 packages & interfaces
Kalai Selvi
 
web program-Inheritance,pack&except in Java.ppt
mcjaya2024
 
Classes and Object Concept Object Oriented Programming in Java
gedeios
 
Objects and classes in OO Programming concepts
researchveltech
 
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 

Similar to OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx (20)

PPT
Java_notes.ppt
tuyambazejeanclaude
 
PDF
Java introduction
Muthukumaran Subramanian
 
PPTX
Inheritance
Munsif Ullah
 
PPTX
Presentation2.ppt java basic core ppt .
KeshavMotivation
 
PPTX
Unit3 part3-packages and interfaces
DevaKumari Vijay
 
PPTX
object oriented programming unit two ppt
isiagnel2
 
PPTX
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
VinishA23
 
PPTX
Chap1 packages
raksharao
 
PPTX
Complete PPT about the Java lokesh kept it
lokeshpappaka10
 
PPTX
ECAP444 - OBJECT ORIENTED PROGRAMMING USING C++.pptx
vmickey4522
 
PPTX
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
PPTX
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
PPTX
Untitled presentation about object oriented.pptx
janetvidyaanancys
 
PPTX
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
PPTX
Java Inheritance - sub class constructors - Method overriding
NithyaN19
 
PPT
Java tutorials
saryu2011
 
PPTX
Software enginnnering introduction (2).pptx
parmidakhrz02
 
PPTX
OCA JAVA - 1 Packages and Class Structure
Fernando Gil
 
PPTX
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
ODP
Synapseindia reviews.odp.
Tarunsingh198
 
Java_notes.ppt
tuyambazejeanclaude
 
Java introduction
Muthukumaran Subramanian
 
Inheritance
Munsif Ullah
 
Presentation2.ppt java basic core ppt .
KeshavMotivation
 
Unit3 part3-packages and interfaces
DevaKumari Vijay
 
object oriented programming unit two ppt
isiagnel2
 
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
VinishA23
 
Chap1 packages
raksharao
 
Complete PPT about the Java lokesh kept it
lokeshpappaka10
 
ECAP444 - OBJECT ORIENTED PROGRAMMING USING C++.pptx
vmickey4522
 
Object Oriented Programming Tutorial.pptx
ethiouniverse
 
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
Untitled presentation about object oriented.pptx
janetvidyaanancys
 
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
Java Inheritance - sub class constructors - Method overriding
NithyaN19
 
Java tutorials
saryu2011
 
Software enginnnering introduction (2).pptx
parmidakhrz02
 
OCA JAVA - 1 Packages and Class Structure
Fernando Gil
 
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
Synapseindia reviews.odp.
Tarunsingh198
 
Ad

More from Tanzila Kehkashan (20)

PPTX
OOP Lecture 25-Network Programming-Part2.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 24-Network Programming-Part1.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 23-JAR Files.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 22-JApplet.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 21-Graphics, Audio.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 20-MultiThreading.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 19-JMenuBar.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 18-DB Connectivity-Part2.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 17-DB Connectivity-Part1.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 16-Math,Timer.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 15-FileHandling,JFileChooser.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 14-ExceptionHandling.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 13-Color,Font,ImageIcon.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 12-EventHandling2.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 11-EventHandling1.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 9-JComboBox,JList,JPanel.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
Tanzila Kehkashan
 
PPTX
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
Tanzila Kehkashan
 
OOP Lecture 25-Network Programming-Part2.pptx
Tanzila Kehkashan
 
OOP Lecture 24-Network Programming-Part1.pptx
Tanzila Kehkashan
 
OOP Lecture 23-JAR Files.pptx
Tanzila Kehkashan
 
OOP Lecture 22-JApplet.pptx
Tanzila Kehkashan
 
OOP Lecture 21-Graphics, Audio.pptx
Tanzila Kehkashan
 
OOP Lecture 20-MultiThreading.pptx
Tanzila Kehkashan
 
OOP Lecture 19-JMenuBar.pptx
Tanzila Kehkashan
 
OOP Lecture 18-DB Connectivity-Part2.pptx
Tanzila Kehkashan
 
OOP Lecture 17-DB Connectivity-Part1.pptx
Tanzila Kehkashan
 
OOP Lecture 16-Math,Timer.pptx
Tanzila Kehkashan
 
OOP Lecture 15-FileHandling,JFileChooser.pptx
Tanzila Kehkashan
 
OOP Lecture 14-ExceptionHandling.pptx
Tanzila Kehkashan
 
OOP Lecture 13-Color,Font,ImageIcon.pptx
Tanzila Kehkashan
 
OOP Lecture 12-EventHandling2.pptx
Tanzila Kehkashan
 
OOP Lecture 11-EventHandling1.pptx
Tanzila Kehkashan
 
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
Tanzila Kehkashan
 
OOP Lecture 9-JComboBox,JList,JPanel.pptx
Tanzila Kehkashan
 
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
Tanzila Kehkashan
 
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
Tanzila Kehkashan
 
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
Tanzila Kehkashan
 
Ad

Recently uploaded (20)

PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PDF
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
PPTX
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Presentation about variables and constant.pptx
safalsingh810
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
vAdobe Premiere Pro 2025 (v25.2.3.004) Crack Pre-Activated Latest
imang66g
 
Can You Build Dashboards Using Open Source Visualization Tool.pptx
Varsha Nayak
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 

OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx

  • 1. CS3135/CS2135 Object Oriented Programming (Java) BSCS-3 / MCS-3 Lecture # 5 Inheritance Dialog boxes Parsing
  • 2. INHERITANCE • Inheritance is the reusability of predefined functionality. • Existing class is called superclass (base class in C++)and new class is called subclass (derived class in C++). • Inheritance is also called Specialization because subclass can modify the behavior of its superclass appropriately to that subclass. • Direct superclass is the superclass from which subclass explicitly inherits. • Indirect superclass is any class above the direct superclass in class hierarchy. • In Java, class hierarchy begins with class Object (in package java.lang), which every class in Java directly or indirectly extends. • Java supports only single inheritance, in which each class is derived from exactly one direct superclass. It does not support multiple inheritance. Instructor: Tanzila Kehkashan 2
  • 3. INHERITANCE A superclass’s • Public members are accessible wherever the program has reference to an object of that superclass or one of its superclass. • Private members can be accessed directly only within the superclass’s declaration. • Protected members have an inheritance level of protection between public and private access. They can be accessed by members of superclass and subclass and other classes in same package. • A superclass’s private methods are hidden in its subclass and can be accessed only through the public or protected methods inherited from the superclass. Relationship between superclass & subclass • A subclass can invoke a constructor of its superclass by using the keyword super followed by a set of parentheses containing the superclass constructor arguments. This must appear as the first statement in the subclass’s constructor body. Example public class person { } public class student extends person { } public class employee extends person { } public class result extends student { } Instructor: Tanzila Kehkashan 3
  • 4. GUI Components • GUI component is an object with which the user interacts via mouse, keyboard or another form of input, such as voice recognition. • These are sometimes called controls or widgets (window gadgets). • Lightweight Vs. Heavyweight GUI components • Swing Vs. AWT components • There are two sets of Java GUI components: • ‘java.awt’ package (Abstract Window Toolkit) • ‘javax.swing’ package Instructor: Tanzila Kehkashan 4
  • 5. GUI Components -> Dialogue Boxes • Simple GUI based I/O with JOptionPane • import javax.swing.JOptionPane; • Message dialog • Input dialog • Option dialog • Confirm dialog • Dialog Constants / message Type • ERROR_MESSAGE • INFORMATION_MESSAGE • WARNING_MESSAGE • QUESTION_MESSAGE • PLAIN_MESSAGE Instructor: Tanzila Kehkashan 5
  • 6. JOptionPane Methods • static void showMessageDialog(Component, Object) • static void showMessageDialog(Component, Object, String, int) • static void showMessageDialog(Component, Object, String, int, Icon) • static int showOptionDialog(Component, Object, String, int, int, Icon, Object[], Object) • static int showConfirmDialog(Component, Object) • static int showConfirmDialog(Component, Object, String, int) • static int showConfirmDialog(Component, Object, String, int, int) • static int showConfirmDialog(Component, Object, String, int, int, Icon) • static String showInputDialog(Object) • static String showInputDialog(Component, Object) • static String showInputDialog(Component, Object, String, int) • static String showInputDialog(Component, Object, String, int, Icon, Object[], Object) Instructor: Tanzila Kehkashan 6
  • 7. GUI Components -> Option Type • DEFAULT_OPTION • YES_NO_OPTION • YES_NO_CANCEL_OPTION • OK_CANCEL_OPTION Return Values • YES_OPTION • NO_OPTION • CANCEL_OPTION • OK_OPTION • CLOSED_OPTION GUI Components -> Dialogue Box Constants Instructor: Tanzila Kehkashan 7
  • 8. Parse methods convert strings to numeric data types. These are • Byte.parseByte(String) • Integer.parseInt(String) • Short.parseShort(String) • Long.parseLong(String) • Float.parseFloat(String) • Double.parseDouble(String) String Parse Instructor: Tanzila Kehkashan 8