SlideShare a Scribd company logo
Java Naming conventions
• class name: It should start with uppercase letter
and be a noun e.g. String, Color, Button, System,
Thread etc.
• interface name: It should start with uppercase
letter and be an adjective e.g. Runnable,
Remote, ActionListener etc.
• method name: It should start with lowercase
letter and be a verb e.g. actionPerformed(),
main(), print(), println() etc.
• variable name: It should start with lowercase
letter e.g. firstName, orderNumber etc.
• package name: It should be in lowercase letter
e.g. java, lang, sql, util etc.
• constants name: It should be in uppercase
letter. e.g. RED, YELLOW, MAX_PRIORITY etc.
• class Student
• {
• int id;
• String name;
• public static void main(String args[])
• {
• Student s1=new Student();
• System.out.println(s1.id);
• System.out.println(s1.name);
• } }
• class Student{
• int id;
• String name;
• }
• class TestStudent1
• {
• public static void main(String args[]){
• Student s1=new Student();
• System.out.println(s1.id);
• System.out.println(s1.name);
• } }
• 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(111,"Karan");  
•   s2.insertRecord(222,"Aryan");  
•   s1.displayInformation();  
•   s2.displayInformation();  
•  }  
• }  
• class Employee{  
•     int id;  
•     String name;  
•     float salary;  
•     void insert(int i, String n, float s) {  
•         id=i;  
•         name=n;  
•         salary=s;  
•     }  
•     void display()
{System.out.println(id+" "+name+" "+salary);}  
• }  
• public class TestEmployee {  
• public static void main(String[] args) {  
•     Employee e1=new Employee();  
•     Employee e2=new Employee();  
•     Employee e3=new Employee();  
•     e1.insert(101,"ajeet",45000);  
•     e2.insert(102,"irfan",25000);  
•     e3.insert(103,"nakul",55000);  
•     e1.display();  
•     e2.display();  
•     e3.display();  }  }  
• class Rectangle
• {  
•  int length;  
•  int width;  
•  void insert(int l, int w){  
•   length=l;  
•   width=w;  
•  }  
•  void calculateArea()
{System.out.println(length*width);}  }  
• class TestRectangle1
• {  
•  public static void main(String args[]){  
•   Rectangle r1=new Rectangle();  
•   Rectangle r2=new Rectangle();  
•   r1.insert(11,5);  
•   r2.insert(3,15);  
•   r1.calculateArea();  
•   r2.calculateArea();  
• }  }  
Constructor in Java
• Constructor in java is  a special type of
method that is used to initialize the object.
• Java  constructor  is invoked at the time of
object creation.  It  constructs  the  values  i.e. 
provides data for  the  object that is why it is 
known as constructor.
Rules for creating java constructor
There are basically two rules defined for the 
constructor.
• Constructor name must be same as its class 
name
• Constructor must have no explicit return type
Types of java constructors
• There are two types of constructors:
• Default constructor (no-arg constructor)
• Parameterized constructor
Example of default constructor
• class Bike1
• {
• Bike1()
• {
• System.out.println("Bike is created");}
• public static void main(String args[]){
• Bike1 b=new Bike1();
• } }
• class Student3{
• int id;
• String name;
• void display()
• {System.out.println(id+" "+name);}
• public static void main(String args[]){
• Student3 s1=new Student3();
• Student3 s2=new Student3();
• s1.display();
• s2.display();
• } }

More Related Content

What's hot

Java Streams
Java StreamsJava Streams
Java Streams
M Vishnuvardhan Reddy
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
Marlom46
 
Operators in java
Operators in javaOperators in java
Operators in java
Then Murugeshwari
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
Abhilash Nair
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Abhilash Nair
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Nilesh Dalvi
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
kunal kishore
 
Java string handling
Java string handlingJava string handling
Java string handling
Salman Khan
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
Abhilash Nair
 
11. java methods
11. java methods11. java methods
11. java methods
M H Buddhika Ariyaratne
 
Generics in java
Generics in javaGenerics in java
Generics in java
suraj pandey
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
kamal kotecha
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpp
rajshreemuthiah
 
Control statements
Control statementsControl statements
Control statements
raksharao
 
Constants in java
Constants in javaConstants in java
Constants in java
Manojkumar C
 

What's hot (20)

Java Streams
Java StreamsJava Streams
Java Streams
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
 
11. java methods
11. java methods11. java methods
11. java methods
 
Generics in java
Generics in javaGenerics in java
Generics in java
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpp
 
Control statements
Control statementsControl statements
Control statements
 
Constants in java
Constants in javaConstants in java
Constants in java
 

Viewers also liked

Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Lovely Professional University
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
Lovely Professional University
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
Lovely Professional University
 
Circular queue
Circular queueCircular queue
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Data structures
Data structuresData structures

Viewers also liked (6)

Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
 
Circular queue
Circular queueCircular queue
Circular queue
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Data structures
Data structuresData structures
Data structures
 

Similar to Java naming conventions

Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
shinyduela
 
Java introduction
Java introductionJava introduction
Java introduction
Samsung Electronics Egypt
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
LovelitJose
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
ssuserb1a18d
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
teach4uin
 
String and string manipulation
String and string manipulationString and string manipulation
String and string manipulation
Shahjahan Samoon
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
PawanMM
 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation x
Shahjahan Samoon
 
Generics
GenericsGenerics
Reading and writting
Reading and writtingReading and writting
Reading and writting
andreeamolnar
 
Explain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).pptExplain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).ppt
ayaankim007
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
Dhiviya Rose
 
Charcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.pptCharcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.ppt
mulualem37
 
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
 
Java
Java Java
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Ayes Chinmay
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
RatnaJava
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptx
adityaraj7711
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
Jevgeni Kabanov
 

Similar to Java naming conventions (20)

Introduction to java programming
Introduction to java programmingIntroduction to java programming
Introduction to java programming
 
Java introduction
Java introductionJava introduction
Java introduction
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
 
String and string manipulation
String and string manipulationString and string manipulation
String and string manipulation
 
Session 08 - OOP with Java - continued
Session 08 - OOP with Java - continuedSession 08 - OOP with Java - continued
Session 08 - OOP with Java - continued
 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation x
 
Generics
GenericsGenerics
Generics
 
Reading and writting
Reading and writtingReading and writting
Reading and writting
 
Explain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).pptExplain Classes and methods in java (ch04).ppt
Explain Classes and methods in java (ch04).ppt
 
CSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and StringsCSEG1001Unit 3 Arrays and Strings
CSEG1001Unit 3 Arrays and Strings
 
Charcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.pptCharcater and Strings.ppt Charcater and Strings.ppt
Charcater and Strings.ppt Charcater and Strings.ppt
 
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
 
Java
Java Java
Java
 
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
Internet and Web Technology (CLASS-16) [Basic Elements of Java Program] | NIC...
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
 
Programing with java for begniers .pptx
Programing with java for begniers  .pptxPrograming with java for begniers  .pptx
Programing with java for begniers .pptx
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 

More from Lovely Professional University

Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Lovely Professional University
 
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Lovely Professional University
 
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Lovely Professional University
 
Programme Management & Project Evaluation
Programme Management & Project EvaluationProgramme Management & Project Evaluation
Programme Management & Project Evaluation
Lovely Professional University
 
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Lovely Professional University
 
Introduction to Software Project Management:
Introduction to Software Project Management:Introduction to Software Project Management:
Introduction to Software Project Management:
Lovely Professional University
 
The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup language
Lovely Professional University
 
Working with JSON
Working with JSONWorking with JSON
Yargs Module
Yargs ModuleYargs Module
NODEMON Module
NODEMON ModuleNODEMON Module
Getting Input from User
Getting Input from UserGetting Input from User
Getting Input from User
Lovely Professional University
 
fs Module.pptx
fs Module.pptxfs Module.pptx
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
Lovely Professional University
 
web_server_browser.ppt
web_server_browser.pptweb_server_browser.ppt
web_server_browser.ppt
Lovely Professional University
 
Web Server.pptx
Web Server.pptxWeb Server.pptx
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
Lovely Professional University
 
Programming Language.ppt
Programming Language.pptProgramming Language.ppt
Programming Language.ppt
Lovely Professional University
 
Information System.pptx
Information System.pptxInformation System.pptx
Information System.pptx
Lovely Professional University
 
Applications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptxApplications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptx
Lovely Professional University
 
Application of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptxApplication of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptx
Lovely Professional University
 

More from Lovely Professional University (20)

Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
Activity Planning: Objectives, Project Schedule, Network Planning Model. Time...
 
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
Effort Estimation: Meaning, Problems with Estimation, Basis, Estimation Techn...
 
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
Project Approach: Intro. Technical Plan, Choice of Process Models: Waterfall,...
 
Programme Management & Project Evaluation
Programme Management & Project EvaluationProgramme Management & Project Evaluation
Programme Management & Project Evaluation
 
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
Step Wise Project Planning: Project Scope, Objectives, Infrastructure, Charac...
 
Introduction to Software Project Management:
Introduction to Software Project Management:Introduction to Software Project Management:
Introduction to Software Project Management:
 
The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup language
 
Working with JSON
Working with JSONWorking with JSON
Working with JSON
 
Yargs Module
Yargs ModuleYargs Module
Yargs Module
 
NODEMON Module
NODEMON ModuleNODEMON Module
NODEMON Module
 
Getting Input from User
Getting Input from UserGetting Input from User
Getting Input from User
 
fs Module.pptx
fs Module.pptxfs Module.pptx
fs Module.pptx
 
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
 
web_server_browser.ppt
web_server_browser.pptweb_server_browser.ppt
web_server_browser.ppt
 
Web Server.pptx
Web Server.pptxWeb Server.pptx
Web Server.pptx
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Programming Language.ppt
Programming Language.pptProgramming Language.ppt
Programming Language.ppt
 
Information System.pptx
Information System.pptxInformation System.pptx
Information System.pptx
 
Applications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptxApplications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptx
 
Application of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptxApplication of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptx
 

Recently uploaded

Levelised Cost of Hydrogen (LCOH) Calculator Manual
Levelised Cost of Hydrogen  (LCOH) Calculator ManualLevelised Cost of Hydrogen  (LCOH) Calculator Manual
Levelised Cost of Hydrogen (LCOH) Calculator Manual
Massimo Talia
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
upoux
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
vmspraneeth
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
MuhammadJazib15
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
wafawafa52
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
Kamal Acharya
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
felixwold
 
P5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civilP5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civil
AnasAhmadNoor
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Open Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surfaceOpen Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surface
Indrajeet sahu
 
Bituminous road construction project based learning report
Bituminous road construction project based learning reportBituminous road construction project based learning report
Bituminous road construction project based learning report
CE19KaushlendraKumar
 
smart pill dispenser is designed to improve medication adherence and safety f...
smart pill dispenser is designed to improve medication adherence and safety f...smart pill dispenser is designed to improve medication adherence and safety f...
smart pill dispenser is designed to improve medication adherence and safety f...
um7474492
 
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
b0754201
 

Recently uploaded (20)

Levelised Cost of Hydrogen (LCOH) Calculator Manual
Levelised Cost of Hydrogen  (LCOH) Calculator ManualLevelised Cost of Hydrogen  (LCOH) Calculator Manual
Levelised Cost of Hydrogen (LCOH) Calculator Manual
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
 
Impartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 StandardImpartiality as per ISO /IEC 17025:2017 Standard
Impartiality as per ISO /IEC 17025:2017 Standard
 
Ericsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.pptEricsson LTE Throughput Troubleshooting Techniques.ppt
Ericsson LTE Throughput Troubleshooting Techniques.ppt
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
 
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdfAsymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
Asymmetrical Repulsion Magnet Motor Ratio 6-7.pdf
 
P5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civilP5 Working Drawings.pdf floor plan, civil
P5 Working Drawings.pdf floor plan, civil
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Open Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surfaceOpen Channel Flow: fluid flow with a free surface
Open Channel Flow: fluid flow with a free surface
 
Bituminous road construction project based learning report
Bituminous road construction project based learning reportBituminous road construction project based learning report
Bituminous road construction project based learning report
 
smart pill dispenser is designed to improve medication adherence and safety f...
smart pill dispenser is designed to improve medication adherence and safety f...smart pill dispenser is designed to improve medication adherence and safety f...
smart pill dispenser is designed to improve medication adherence and safety f...
 
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
 

Java naming conventions

  • 1. Java Naming conventions • class name: It should start with uppercase letter and be a noun e.g. String, Color, Button, System, Thread etc. • interface name: It should start with uppercase letter and be an adjective e.g. Runnable, Remote, ActionListener etc. • method name: It should start with lowercase letter and be a verb e.g. actionPerformed(), main(), print(), println() etc.
  • 2. • variable name: It should start with lowercase letter e.g. firstName, orderNumber etc. • package name: It should be in lowercase letter e.g. java, lang, sql, util etc. • constants name: It should be in uppercase letter. e.g. RED, YELLOW, MAX_PRIORITY etc.
  • 3. • class Student • { • int id; • String name; • public static void main(String args[]) • { • Student s1=new Student(); • System.out.println(s1.id); • System.out.println(s1.name); • } }
  • 4. • class Student{ • int id; • String name; • } • class TestStudent1 • { • public static void main(String args[]){ • Student s1=new Student(); • System.out.println(s1.id); • System.out.println(s1.name); • } }
  • 5. • class Student{   •  int rollno;   •  String name;   •  void insertRecord(int r, String n){   •   rollno=r;   •   name=n;   •  }   • void displayInformation() • {System.out.println(rollno+" "+name);}   • }  
  • 6. •  class TestStudent4{   •  public static void main(String args[]){   •   Student s1=new Student();   •   Student s2=new Student();   •   s1.insertRecord(111,"Karan");   •   s2.insertRecord(222,"Aryan");   •   s1.displayInformation();   •   s2.displayInformation();   •  }   • }  
  • 7. • class Employee{   •     int id;   •     String name;   •     float salary;   •     void insert(int i, String n, float s) {   •         id=i;   •         name=n;   •         salary=s;   •     }   •     void display() {System.out.println(id+" "+name+" "+salary);}   • }  
  • 8. • public class TestEmployee {   • public static void main(String[] args) {   •     Employee e1=new Employee();   •     Employee e2=new Employee();   •     Employee e3=new Employee();   •     e1.insert(101,"ajeet",45000);   •     e2.insert(102,"irfan",25000);   •     e3.insert(103,"nakul",55000);   •     e1.display();   •     e2.display();   •     e3.display();  }  }  
  • 9. • class Rectangle • {   •  int length;   •  int width;   •  void insert(int l, int w){   •   length=l;   •   width=w;   •  }   •  void calculateArea() {System.out.println(length*width);}  }  
  • 10. • class TestRectangle1 • {   •  public static void main(String args[]){   •   Rectangle r1=new Rectangle();   •   Rectangle r2=new Rectangle();   •   r1.insert(11,5);   •   r2.insert(3,15);   •   r1.calculateArea();   •   r2.calculateArea();   • }  }  
  • 11. Constructor in Java • Constructor in java is  a special type of method that is used to initialize the object. • Java  constructor  is invoked at the time of object creation.  It  constructs  the  values  i.e.  provides data for  the  object that is why it is  known as constructor.
  • 13. Types of java constructors • There are two types of constructors: • Default constructor (no-arg constructor) • Parameterized constructor
  • 14. Example of default constructor • class Bike1 • { • Bike1() • { • System.out.println("Bike is created");} • public static void main(String args[]){ • Bike1 b=new Bike1(); • } }
  • 15. • class Student3{ • int id; • String name; • void display() • {System.out.println(id+" "+name);} • public static void main(String args[]){ • Student3 s1=new Student3(); • Student3 s2=new Student3(); • s1.display(); • s2.display(); • } }