0% found this document useful (0 votes)
6 views

Class 2

Uploaded by

M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Class 2

Uploaded by

M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Naming conventions in Java

===========================
In java, uppercase letters will consider as different and lowercase letters will
consider as
different.Hence we consider java is a case sensitive programming language.

As java is a case sensitive, we must and should follow naming conventions for
following things.

ex:
classes
interfaces
variables
methods
keywords
packages and
constants

classes
--------
In java, a class name must and should starts with uppercase letter and if it
contains multiple
words then each inner word must starts with initcap.

ex:
predefined classes userdefined classes
-------------------- ---------------------
System Test
FileWriter DemoApp
BufferedReader ExampleApp
File EmployeeDetails
StringBuilder StudentInfo
and etc. and etc.

interfaces
-----------
In java, an interface name must and should starts with uppercase letter and if it
contains
multiple words then each inner word must and should starts with initcap.

ex:
predefined interfaces userdefined interfaces
--------------------- ---------------------
Runnable ITest
Serializable IDemoApp
ListIterator IStudentInfo
Enumeration IDepartment
and etc. and etc.

variables
---------
In java, a variable name must and should starts with lowercase letter and if it
contains multiple
words then each inner word must and should starts with initcap.

ex:
predefined variables userdefined variables
--------------------- ---------------------
out i
in empId
err studName
length deptNo
and etc. and etc.

Methods
--------
In java, a method name must and should starts with lowercase letter and if it
contains multiple
words then each inner word must and should starts with initcap.

ex:
predefined methods userdefined methods
------------------- --------------------
getPriority() getStudentInfo()
setName() setBillDetails()
getClass() calculateBillAmt()
hashCode() and etc.
toString()
and etc.

keywords
--------
In java, all keywords we need to declare under lowercase letters only.

ex:
predefined keywords
-------------------
if , else, do, while, break, public, static, void and etc.

packages
----------
In java, all packages we need to declare under lowercase letters only.

ex:
predefined packages userdefined packages
----------------- --------------------
java.lang com.ihub.www
java.util com.google.www
java.time com.qt.www
java.text and etc.
java.util.stream
java.sql
and etc.

constants
-----------
In java, all constants we need to declare under uppercase letters only.

ex:
predefined constants userdefined constants
----------------- -------------------
MAX_PRIORITY LIMIT=10;
MIN_PRIORITY
NORM_PRIORITY
MAX_VALUE
MIN_VALUE
and etc.

Assignment
===========
1) class : QualityThought

2) Interface : IQualityThought

3) variable : qualityThought

4) Method : qualityThought()

5) package : com.qualitythought.www

6) constant : QUALITY_THOUGHT

Interview Questions
===================

Q) Which package is a default package in java?

java.lang package

Q) What is package?

A package is a collection of classes and interfaces.

You might also like