SlideShare ist ein Scribd-Unternehmen logo
1 von 18
N ART ADAR SARASAWATHI COLLEGE OF
ART &SCIENCE,Theni
METHODS AND CLASSES
 It examies several topics relating to
methods,including overloading,parameter,passing and
recrsion.
 The class , discussing access control , the use of the
keyword staic , and or of java’s most important
built-in classes string.
Overloading methods
 When this is the case the methods are said to be
overloading and the process is referred to as method
overloading.
 Thus overloaded methods must may have different
return/or number of their parameters.
 two versions of a method :
Overloaded method
Simply executes method
 As you can see test() is overloaded four times.
 at no parameters,
 The first version takes no parameters,
 The second takes integer parameter,s
 Third tat the takes two integer parameters,
 Fourth takes one double parameter.
 The fact that the fourth of test() also return a value is
of no consequence relative to overloaded.
 Since return types do not play a role in overload
resolution.
Using objects as parameters
 As you can , see the equal() method inside Test
compares two objects for equality and return the
result.
 If they contain the same values, that then the method
return true.
 Otherwise it return false. Notice that the parameter o
in equals() Test as its type.
 Version of Box allows one object to initialize.
A closer look at argument passing
 There are two way is that a language.
 The first way is call-by-value.
 Value of argument into the formal parameter of the
subroutine.
 The second way an argument can be passed is call-
by-reference.
 Not value of the argument.
 Operation that occur inside meth() have no effect on
the values of a and b used in the call;
Returning objects
 A method can return any type of data including class
type that you create.
 incrByTen() meyhod.
 As you each time incrByTen() is invoked new object is
created and a reference to is returned to the calling
routine.
 The all object are dynamically allocated using new, you
don’t need to worry about an object going out-of-
scope.
recursion
 Java support recursion.
 A method that calls itself is said to be recursive.
 The classic example recursion product of all the whole
numbers between 1 and N of the factorial of number.
 for example 3 factorial 1*2*3, or 6.
 Use println() statements liberally during development
.
Introducing Access Control
 As you know encapsulation link data with the code that
manipulates.
 Encapsulation provide another another important
attritube: access control.
 Correctly implemented a class create a “black box inner
working not open to tempering.
 For example consider the stack class end of true the
methods push() and pop()provide a controlled interface to
the stack not enforced.
 Java’s access speccifiers are
public,private,protected.
 Protected applies only when inheritance.
 Let’s begin by defining public and private. when a
member of a class is modified a the public specified
then the member can be accessed by any other code.
 Public methods:
 setc() and get().
 Remove the comment symbol from the beginning of
the.
 ob.c=100;
Understanding static
 There will be times when you will want to define a class
member that will be used independently of any object of
that class.
 When a member is decleared static it can be accessed
before any objects of class are created.
 Example : static main() decleared as static called before
any objects exist.
 Methods declared as static methods:
 They can only call other static methods.
 They must only access static data.
 They cannot refer to this or super in any way.
 static method from outside its class,
classname.method()
• Inside main(),the static method callme() and
static variable b are accessed through class name
staticDemo.
Introducing final
 A variable can be declared as final.
 Subsequent parts of your program can now use
FILE_OPEN,etc., as if they were constants,without
fear that a value has been changed.
 Thus final variable is essentially a constant.
 This second usage of final is described in the next
inheritance is described.
Array revisited
 Now that you know about classes, an important point
can about about arrays:
 The size of an array-that is the number of element that
an array can hold-is found in its length instance
variable.
 Program create two stacks:
 one five elements other eight element deep.
 array maintain their own length own information
makes easy create stacks of any size.
 Inner class named Inner within scope of class Outer.
 Inner can directly access the variable outer_x.
 The main() method of InnerClassDemo creates
an instance of class outer and invokes its test()
method.
 Instance variable of showy().
Introducing nested and inner meth
classes
 Such classes are known as nested classes.
 There are two type of nested classess:
 static and non-static.
 The most important type of static nested classes inner
class.
 The class named outer has one instance variable
named outer_x, one instance method named test()
and defines inner called inner.
 Inner class named Inner is defined scope class Outer.
Exploring the string class
 String is probably the most commonly used in java’s
class library.
• Even string constants are actually string objects.
• If you need to change a string can always create a new
one that contains the modifications.
• Java defines a peer class String called StringBufffer,
• “I like Java”.
Using command-line arguments
 This is accompolihed passing command-line
arguments to main().
 A command –line argument is the information that
directly follow the program’s name on the command
line when is executed.
 The first command line argument is stored at args[0]
 The second a args[1]

Weitere ähnliche Inhalte

Was ist angesagt?

Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods javaPadma Kannan
 
Mutable and immutable classes
Mutable and  immutable classesMutable and  immutable classes
Mutable and immutable classesTech_MX
 
Ap Power Point Chpt8
Ap Power Point Chpt8Ap Power Point Chpt8
Ap Power Point Chpt8dplunkett
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functionsHarsh Patel
 
Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7dplunkett
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaMOHIT AGARWAL
 
Java As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsJava As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsHelen SagayaRaj
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby MetaprogrammingWei Jen Lu
 
البرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالالبرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالMahmoud Alfarra
 
Effective Java - Chapter 3: Methods Common to All Objects
Effective Java - Chapter 3: Methods Common to All ObjectsEffective Java - Chapter 3: Methods Common to All Objects
Effective Java - Chapter 3: Methods Common to All Objectsİbrahim Kürce
 
2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++Jeff TUYISHIME
 
Ap Power Point Chpt5
Ap Power Point Chpt5Ap Power Point Chpt5
Ap Power Point Chpt5dplunkett
 
Java - Class Structure
Java - Class StructureJava - Class Structure
Java - Class StructureVicter Paul
 
Classes and Objects in C#
Classes and Objects in C#Classes and Objects in C#
Classes and Objects in C#Adeel Rasheed
 

Was ist angesagt? (20)

Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods java
 
LISP:Object System Lisp
LISP:Object System LispLISP:Object System Lisp
LISP:Object System Lisp
 
Mutable and immutable classes
Mutable and  immutable classesMutable and  immutable classes
Mutable and immutable classes
 
Ap Power Point Chpt8
Ap Power Point Chpt8Ap Power Point Chpt8
Ap Power Point Chpt8
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Array
ArrayArray
Array
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Java As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsJava As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & Applets
 
Method of java
Method of javaMethod of java
Method of java
 
Ruby Metaprogramming
Ruby MetaprogrammingRuby Metaprogramming
Ruby Metaprogramming
 
C# Types of classes
C# Types of classesC# Types of classes
C# Types of classes
 
البرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكالالبرمجة الهدفية بلغة جافا - تعدد الأشكال
البرمجة الهدفية بلغة جافا - تعدد الأشكال
 
Effective Java - Chapter 3: Methods Common to All Objects
Effective Java - Chapter 3: Methods Common to All ObjectsEffective Java - Chapter 3: Methods Common to All Objects
Effective Java - Chapter 3: Methods Common to All Objects
 
2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++2 lesson 2 object oriented programming in c++
2 lesson 2 object oriented programming in c++
 
Ap Power Point Chpt5
Ap Power Point Chpt5Ap Power Point Chpt5
Ap Power Point Chpt5
 
Java - Class Structure
Java - Class StructureJava - Class Structure
Java - Class Structure
 
Classes and Objects in C#
Classes and Objects in C#Classes and Objects in C#
Classes and Objects in C#
 

Ähnlich wie Hemajava

9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08Terry Yoast
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...vekariyakashyap
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesSakkaravarthiS1
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slotsmha4
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slotsmha4
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Threeamiable_indian
 
CIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaCIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaHamad Odhabi
 
CJP Unit-1 contd.pptx
CJP Unit-1 contd.pptxCJP Unit-1 contd.pptx
CJP Unit-1 contd.pptxRAJASEKHARV10
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfacesmadhavi patil
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 

Ähnlich wie Hemajava (20)

Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08
 
OOPs & Inheritance Notes
OOPs & Inheritance NotesOOPs & Inheritance Notes
OOPs & Inheritance Notes
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 
Inheritance
InheritanceInheritance
Inheritance
 
Java defining classes
Java defining classes Java defining classes
Java defining classes
 
Introduction to Python - Part Three
Introduction to Python - Part ThreeIntroduction to Python - Part Three
Introduction to Python - Part Three
 
Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
CIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in JavaCIS 1403 lab 3 functions and methods in Java
CIS 1403 lab 3 functions and methods in Java
 
Java class
Java classJava class
Java class
 
Core java oop
Core java oopCore java oop
Core java oop
 
CJP Unit-1 contd.pptx
CJP Unit-1 contd.pptxCJP Unit-1 contd.pptx
CJP Unit-1 contd.pptx
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 

Mehr von SangeethaSasi1 (20)

L4 multiplexing & multiple access 16
L4 multiplexing & multiple access 16L4 multiplexing & multiple access 16
L4 multiplexing & multiple access 16
 
Image processing using matlab
Image processing using matlab Image processing using matlab
Image processing using matlab
 
Mc ppt
Mc pptMc ppt
Mc ppt
 
Mc ppt
Mc pptMc ppt
Mc ppt
 
Dip pppt
Dip ppptDip pppt
Dip pppt
 
Web techh
Web techhWeb techh
Web techh
 
Web tech
Web techWeb tech
Web tech
 
Vani wt
Vani wtVani wt
Vani wt
 
Vani dbms
Vani dbmsVani dbms
Vani dbms
 
Hema wt (1)
Hema wt (1)Hema wt (1)
Hema wt (1)
 
Hema rdbms
Hema rdbmsHema rdbms
Hema rdbms
 
Web tech
Web techWeb tech
Web tech
 
Web tech
Web techWeb tech
Web tech
 
Dbms
DbmsDbms
Dbms
 
Vani
VaniVani
Vani
 
Hema se
Hema seHema se
Hema se
 
Software
SoftwareSoftware
Software
 
Operating system
Operating systemOperating system
Operating system
 
Dataminng
DataminngDataminng
Dataminng
 
System calls
System callsSystem calls
System calls
 

Kürzlich hochgeladen

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 

Kürzlich hochgeladen (20)

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 

Hemajava

  • 1. N ART ADAR SARASAWATHI COLLEGE OF ART &SCIENCE,Theni
  • 2. METHODS AND CLASSES  It examies several topics relating to methods,including overloading,parameter,passing and recrsion.  The class , discussing access control , the use of the keyword staic , and or of java’s most important built-in classes string.
  • 3. Overloading methods  When this is the case the methods are said to be overloading and the process is referred to as method overloading.  Thus overloaded methods must may have different return/or number of their parameters.  two versions of a method : Overloaded method Simply executes method
  • 4.  As you can see test() is overloaded four times.  at no parameters,  The first version takes no parameters,  The second takes integer parameter,s  Third tat the takes two integer parameters,  Fourth takes one double parameter.  The fact that the fourth of test() also return a value is of no consequence relative to overloaded.  Since return types do not play a role in overload resolution.
  • 5. Using objects as parameters  As you can , see the equal() method inside Test compares two objects for equality and return the result.  If they contain the same values, that then the method return true.  Otherwise it return false. Notice that the parameter o in equals() Test as its type.  Version of Box allows one object to initialize.
  • 6. A closer look at argument passing  There are two way is that a language.  The first way is call-by-value.  Value of argument into the formal parameter of the subroutine.  The second way an argument can be passed is call- by-reference.  Not value of the argument.  Operation that occur inside meth() have no effect on the values of a and b used in the call;
  • 7. Returning objects  A method can return any type of data including class type that you create.  incrByTen() meyhod.  As you each time incrByTen() is invoked new object is created and a reference to is returned to the calling routine.  The all object are dynamically allocated using new, you don’t need to worry about an object going out-of- scope.
  • 8. recursion  Java support recursion.  A method that calls itself is said to be recursive.  The classic example recursion product of all the whole numbers between 1 and N of the factorial of number.  for example 3 factorial 1*2*3, or 6.  Use println() statements liberally during development .
  • 9. Introducing Access Control  As you know encapsulation link data with the code that manipulates.  Encapsulation provide another another important attritube: access control.  Correctly implemented a class create a “black box inner working not open to tempering.  For example consider the stack class end of true the methods push() and pop()provide a controlled interface to the stack not enforced.  Java’s access speccifiers are public,private,protected.  Protected applies only when inheritance.
  • 10.  Let’s begin by defining public and private. when a member of a class is modified a the public specified then the member can be accessed by any other code.  Public methods:  setc() and get().  Remove the comment symbol from the beginning of the.  ob.c=100;
  • 11. Understanding static  There will be times when you will want to define a class member that will be used independently of any object of that class.  When a member is decleared static it can be accessed before any objects of class are created.  Example : static main() decleared as static called before any objects exist.  Methods declared as static methods:  They can only call other static methods.  They must only access static data.  They cannot refer to this or super in any way.
  • 12.  static method from outside its class, classname.method() • Inside main(),the static method callme() and static variable b are accessed through class name staticDemo.
  • 13. Introducing final  A variable can be declared as final.  Subsequent parts of your program can now use FILE_OPEN,etc., as if they were constants,without fear that a value has been changed.  Thus final variable is essentially a constant.  This second usage of final is described in the next inheritance is described.
  • 14. Array revisited  Now that you know about classes, an important point can about about arrays:  The size of an array-that is the number of element that an array can hold-is found in its length instance variable.  Program create two stacks:  one five elements other eight element deep.  array maintain their own length own information makes easy create stacks of any size.
  • 15.  Inner class named Inner within scope of class Outer.  Inner can directly access the variable outer_x.  The main() method of InnerClassDemo creates an instance of class outer and invokes its test() method.  Instance variable of showy().
  • 16. Introducing nested and inner meth classes  Such classes are known as nested classes.  There are two type of nested classess:  static and non-static.  The most important type of static nested classes inner class.  The class named outer has one instance variable named outer_x, one instance method named test() and defines inner called inner.  Inner class named Inner is defined scope class Outer.
  • 17. Exploring the string class  String is probably the most commonly used in java’s class library. • Even string constants are actually string objects. • If you need to change a string can always create a new one that contains the modifications. • Java defines a peer class String called StringBufffer, • “I like Java”.
  • 18. Using command-line arguments  This is accompolihed passing command-line arguments to main().  A command –line argument is the information that directly follow the program’s name on the command line when is executed.  The first command line argument is stored at args[0]  The second a args[1]