SlideShare a Scribd company logo
PRESENTED BY:-
SURESH MOHTA
A class is a blueprint of a set of objects that have a common
behaviour. Based on the blueprint, actual objects are created. In
simple words, a class is defines an outline, based on which actual
objects are created. A class can contain fields and methods to
describe the behaviour of an object. In general, class declarations
can include these components, in order:
 Modifiers : A class can be public or has default access .
1) Class name: The name should begin with a initial letter
(capitalized by convention).
2) Superclass(if any): The name of the class’s parent (superclass), if
any, preceded by the keyword extends. A class can only extend
(subclass) one parent.
3) Interfaces(if any): A comma-separated list of interfaces
implemented by the class, if any, preceded by the keyword
implements. A class can implement more than one interface.
4) Body: The class body is surrounded by braces, { }.
 Class is a user defined data type
 Variables and functions can be created with in a class
 Syntax:
class classname[extends superclassname]
{
[fields declaration];
[method declaration];
}
 Example:
class Area
{
int length;
int breadth;
}
A class is a blueprint from which individual objects are created.
A class can contain any of the following variable types.
 Local variables − Variables defined inside methods, constructors or
blocks are called local variables. The variable will be declared and
initialized within the method and the variable will be destroyed when
the method has completed.
 Instance variables − Instance variables are variables within a class
but outside any method. These variables are initialized when the
class is instantiated. Instance variables can be accessed from inside
any method, constructor or blocks of that particular class.
 Class variables − Class variables are variables declared within a
class, outside any method, with the static keyword.
A class can have any number of methods to access the value of various
kinds of methods. In the example, barking(), hungry() and sleeping() are
methods.
public class Dog {
String breed;
int age;
String color;
void barking() {
}
void hungry() {
}
void sleeping() {
}
}
 It is a basic unit of Object Oriented Programming and
represents the real life entities. A typical Java
program creates many objects, which as you know,
interact by invoking methods. An object consists of :
 State : It is represented by attributes of an object. It
also reflects the properties of an object.
 Behaviour : It is represented by methods of an object.
It also reflects the response of an object with other
objects.
 Identity : It gives a unique name to an object and
enables one object to interact with other objects.
 Example of an object: dog
class Student
{
int rollno;
String name;
void insertRecord(int r, String n)
{
rollno=r;
name=n;
}
void displayInformation(){System.out.println(rollno+" "+name);}
}
class TestStudent4
{
public static void main(String args[])
{
Student s1=new Student();
Student s2=new Student();
s1.insertRecord(29,“Sumit");
s2.insertRecord(30,“Suresh");
s1.displayInformation();
s2.displayInformation();
}
}
Output: 29 Sumit
30 Suresh
 A method is a named piece of code within a
program and executes when it is called from
another section of code.
 Now we will see how to create a methods with
or without return values, invoke a method with
or without parameters, and apply method
abstraction in the program design.
 In java, without methods class has no LIFE.
 Methods are essential for manipulating the
data in program.
 Methods are the interface or communications between program
components.
 In java, a method must be defined before it is used anywhere in the
program.
SYNTAX: Example:
Type methodname(parameter list) public class Cube
{ {
method body; int length;
} int breadth;
int height;
Public int getVolume()
{
return(length*breadth*height);
} }
Note: type of the value method return.-it can be void,int,double etc.
 If a class have multiple methods by same name but
different parameters, it is known as Method
Overloading. If we have to perform only one
operation, having same name of the methods
increases the readability of the program.
 Method Overloading is also known as Static
Polymorphism.
 Static Polymorphism is also known as compile time
binding or early binding.
 Static Binding happens at compile time. Method
Overloading is an example of static binding where
binding of method call to its definition happens at
compile time.
 If subclass (child class) has the same method
as declared in the parent class, it is known as
Method Overriding in Java.
 In other words, if subclass provides the
specific implementation of the method that
has been provided by one of its parent class,
it is known as Method Overriding.
ADVANTAGE : The main advantage of method
overriding is that the class can give its own
specific implementation to a inherited
method without even modifying the parent
class(base class).
OVERLOADING-
class sum{
void add(int a, int b){
System.out.println(“sum of two
=”+(a+b)); }
void add(int a, int b, int c){
System.out.println(“sum of
three=“+(a+b+c)); }
}
class Polymorphism {
public static void main(String
args[]) {
Sum s=new Sum();
s.add(10,15); s.add(10,20,30);}
}
o/p:- Sum of two=25
Sum of three=60
OVERRIDING-
class A{
void fun(){
System.out.println(“HELLO”); } }
class B extends A{
void fun() {
System.out.println(“HI”); } }
class c {
public static void main(String
args[]) }
B ob=new B();
ob.fun();
A ob1=new A();
Ob1.fun(); }
}
o/p:- HI
HELLO
A command-line argument is the
information that follows the name of the program
on the command line of the operating system. The
java command-line argument is an argument that
is passed at the time of running of the java
program.
The arguments passed from the
console can be received in the java program and it
can be used as an input.
Command line argument provides a
convenient way to check the behaviour of the
program for the different values. We can pass N
(1,2,3 and so on) numbers of arguments from the
command prompt.
To access the command-line
arguments inside a Java program is quite easy.
They are stored as strings in the String array
passed to main().
Command line argument is used to
pass the argument at the time when we write the
command to run any program.
The following program of command line
argument displays only one argument that
it is called with-
class Commandline{
public static void main(String args[]){
System.out.println(“First argument is :”+
args[0]);
}
}
compile by > javac CommandLine.java
run by > java CommandLine suresh
OUTPUT:
First argument is: suresh
The following program displays all of the
command line arguments that is called with-
class CommandLine {
public static void main(String args[]) {
for(int i=0;i<args.length;i++) {
System.out.println(“args[“+ i +”]:“+ args[i]);
}
}
}
 // Try executing this:
 $java CommandLine this is a command line
10
 Output
 args[0]:this
args[1]: is
args[2]: a
args[3]: command
args[4]: line
args[5]: 10
Basic concept of class, method , command line-argument

More Related Content

What's hot

encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloading
Shivam Singhal
 
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
MOHIT AGARWAL
 
Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear
ASHNA nadhm
 
Main method in java
Main method in javaMain method in java
Main method in java
Hitesh Kumar
 
11. java methods
11. java methods11. java methods
11. java methods
M H Buddhika Ariyaratne
 
Lecture 4_Java Method-constructor_imp_keywords
Lecture   4_Java Method-constructor_imp_keywordsLecture   4_Java Method-constructor_imp_keywords
Lecture 4_Java Method-constructor_imp_keywords
manish kumar
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
CharthaGaglani
 
Computer programming 2 Lesson 15
Computer programming 2  Lesson 15Computer programming 2  Lesson 15
Computer programming 2 Lesson 15
MLG College of Learning, Inc
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
CPD INDIA
 
Overloading and overriding in vb.net
Overloading and overriding in vb.netOverloading and overriding in vb.net
Overloading and overriding in vb.net
suraj pandey
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
manish kumar
 
Abstract method
Abstract methodAbstract method
Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods
Bhanwar Singh Meena
 
Chapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and PolymorphismChapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and Polymorphism
Eduardo Bergavera
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
tigerwarn
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
baabtra.com - No. 1 supplier of quality freshers
 

What's hot (20)

encapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloadingencapsulation, inheritance, overriding, overloading
encapsulation, inheritance, overriding, overloading
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
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
 
Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear
 
Main method in java
Main method in javaMain method in java
Main method in java
 
11. java methods
11. java methods11. java methods
11. java methods
 
Lecture 4_Java Method-constructor_imp_keywords
Lecture   4_Java Method-constructor_imp_keywordsLecture   4_Java Method-constructor_imp_keywords
Lecture 4_Java Method-constructor_imp_keywords
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
 
Computer programming 2 Lesson 15
Computer programming 2  Lesson 15Computer programming 2  Lesson 15
Computer programming 2 Lesson 15
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Overloading and overriding in vb.net
Overloading and overriding in vb.netOverloading and overriding in vb.net
Overloading and overriding in vb.net
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
 
OOP java
OOP javaOOP java
OOP java
 
Abstract method
Abstract methodAbstract method
Abstract method
 
Abstract classes
Abstract classesAbstract classes
Abstract classes
 
Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods
 
Chapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and PolymorphismChapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and Polymorphism
 
Hemajava
HemajavaHemajava
Hemajava
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Method overloading and constructor overloading in java
Method overloading and constructor overloading in javaMethod overloading and constructor overloading in java
Method overloading and constructor overloading in java
 

Similar to Basic concept of class, method , command line-argument

Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
DevaKumari Vijay
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
ilias ahmed
 
Lecture 8 Library classes
Lecture 8 Library classesLecture 8 Library classes
Lecture 8 Library classes
Syed Afaq Shah MACS CP
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
Khaled Anaqwa
 
C# program structure
C# program structureC# program structure
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
AnmolVerma363503
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10Terry Yoast
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Ayes Chinmay
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
Gousalya Ramachandran
 
Core java oop
Core java oopCore java oop
Core java oop
Parth Shah
 
Oop in kotlin
Oop in kotlinOop in kotlin
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
SakkaravarthiS1
 
Chapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).pptChapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).ppt
henokmetaferia1
 
Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
ssuser8347a1
 
Java mcq
Java mcqJava mcq
Java mcq
avinash9821
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
Inocentshuja Ahmad
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
Maryo Manjaruni
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 

Similar to Basic concept of class, method , command line-argument (20)

Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
Oop features java presentationshow
Oop features java presentationshowOop features java presentationshow
Oop features java presentationshow
 
Lecture 8 Library classes
Lecture 8 Library classesLecture 8 Library classes
Lecture 8 Library classes
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Chap11
Chap11Chap11
Chap11
 
C# program structure
C# program structureC# program structure
C# program structure
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
Core java oop
Core java oopCore java oop
Core java oop
 
Oop in kotlin
Oop in kotlinOop in kotlin
Oop in kotlin
 
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
 
Chapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).pptChapter 5 (OOP Principles).ppt
Chapter 5 (OOP Principles).ppt
 
Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
 
Java mcq
Java mcqJava mcq
Java mcq
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
 
Jedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented conceptsJedi slides 2.1 object-oriented concepts
Jedi slides 2.1 object-oriented concepts
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 

Recently uploaded

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 

Recently uploaded (20)

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 

Basic concept of class, method , command line-argument

  • 2. A class is a blueprint of a set of objects that have a common behaviour. Based on the blueprint, actual objects are created. In simple words, a class is defines an outline, based on which actual objects are created. A class can contain fields and methods to describe the behaviour of an object. In general, class declarations can include these components, in order:  Modifiers : A class can be public or has default access . 1) Class name: The name should begin with a initial letter (capitalized by convention). 2) Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the keyword extends. A class can only extend (subclass) one parent. 3) Interfaces(if any): A comma-separated list of interfaces implemented by the class, if any, preceded by the keyword implements. A class can implement more than one interface. 4) Body: The class body is surrounded by braces, { }.
  • 3.  Class is a user defined data type  Variables and functions can be created with in a class  Syntax: class classname[extends superclassname] { [fields declaration]; [method declaration]; }  Example: class Area { int length; int breadth; }
  • 4. A class is a blueprint from which individual objects are created. A class can contain any of the following variable types.  Local variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.  Instance variables − Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.  Class variables − Class variables are variables declared within a class, outside any method, with the static keyword. A class can have any number of methods to access the value of various kinds of methods. In the example, barking(), hungry() and sleeping() are methods.
  • 5. public class Dog { String breed; int age; String color; void barking() { } void hungry() { } void sleeping() { } }
  • 6.  It is a basic unit of Object Oriented Programming and represents the real life entities. A typical Java program creates many objects, which as you know, interact by invoking methods. An object consists of :  State : It is represented by attributes of an object. It also reflects the properties of an object.  Behaviour : It is represented by methods of an object. It also reflects the response of an object with other objects.  Identity : It gives a unique name to an object and enables one object to interact with other objects.  Example of an object: dog
  • 7.
  • 8. class Student { int rollno; String name; void insertRecord(int r, String n) { rollno=r; name=n; } void displayInformation(){System.out.println(rollno+" "+name);} } class TestStudent4 { public static void main(String args[]) {
  • 9. Student s1=new Student(); Student s2=new Student(); s1.insertRecord(29,“Sumit"); s2.insertRecord(30,“Suresh"); s1.displayInformation(); s2.displayInformation(); } } Output: 29 Sumit 30 Suresh
  • 10.  A method is a named piece of code within a program and executes when it is called from another section of code.  Now we will see how to create a methods with or without return values, invoke a method with or without parameters, and apply method abstraction in the program design.  In java, without methods class has no LIFE.  Methods are essential for manipulating the data in program.
  • 11.  Methods are the interface or communications between program components.  In java, a method must be defined before it is used anywhere in the program. SYNTAX: Example: Type methodname(parameter list) public class Cube { { method body; int length; } int breadth; int height; Public int getVolume() { return(length*breadth*height); } } Note: type of the value method return.-it can be void,int,double etc.
  • 12.  If a class have multiple methods by same name but different parameters, it is known as Method Overloading. If we have to perform only one operation, having same name of the methods increases the readability of the program.  Method Overloading is also known as Static Polymorphism.  Static Polymorphism is also known as compile time binding or early binding.  Static Binding happens at compile time. Method Overloading is an example of static binding where binding of method call to its definition happens at compile time.
  • 13.  If subclass (child class) has the same method as declared in the parent class, it is known as Method Overriding in Java.  In other words, if subclass provides the specific implementation of the method that has been provided by one of its parent class, it is known as Method Overriding. ADVANTAGE : The main advantage of method overriding is that the class can give its own specific implementation to a inherited method without even modifying the parent class(base class).
  • 14. OVERLOADING- class sum{ void add(int a, int b){ System.out.println(“sum of two =”+(a+b)); } void add(int a, int b, int c){ System.out.println(“sum of three=“+(a+b+c)); } } class Polymorphism { public static void main(String args[]) { Sum s=new Sum(); s.add(10,15); s.add(10,20,30);} } o/p:- Sum of two=25 Sum of three=60 OVERRIDING- class A{ void fun(){ System.out.println(“HELLO”); } } class B extends A{ void fun() { System.out.println(“HI”); } } class c { public static void main(String args[]) } B ob=new B(); ob.fun(); A ob1=new A(); Ob1.fun(); } } o/p:- HI HELLO
  • 15. A command-line argument is the information that follows the name of the program on the command line of the operating system. The java command-line argument is an argument that is passed at the time of running of the java program. The arguments passed from the console can be received in the java program and it can be used as an input.
  • 16. Command line argument provides a convenient way to check the behaviour of the program for the different values. We can pass N (1,2,3 and so on) numbers of arguments from the command prompt. To access the command-line arguments inside a Java program is quite easy. They are stored as strings in the String array passed to main(). Command line argument is used to pass the argument at the time when we write the command to run any program.
  • 17. The following program of command line argument displays only one argument that it is called with- class Commandline{ public static void main(String args[]){ System.out.println(“First argument is :”+ args[0]); } }
  • 18. compile by > javac CommandLine.java run by > java CommandLine suresh OUTPUT: First argument is: suresh
  • 19. The following program displays all of the command line arguments that is called with- class CommandLine { public static void main(String args[]) { for(int i=0;i<args.length;i++) { System.out.println(“args[“+ i +”]:“+ args[i]); } } }
  • 20.  // Try executing this:  $java CommandLine this is a command line 10  Output  args[0]:this args[1]: is args[2]: a args[3]: command args[4]: line args[5]: 10