Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Java 4

The document discusses Java naming conventions for classes, interfaces, variables, methods, keywords, packages and constants. Classes and interfaces must start with an uppercase letter, variables and methods start with lowercase, keywords and packages are lowercase, and constants are uppercase.

Uploaded by

umamucheli34
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java 4

The document discusses Java naming conventions for classes, interfaces, variables, methods, keywords, packages and constants. Classes and interfaces must start with an uppercase letter, variables and methods start with lowercase, keywords and packages are lowercase, and constants are uppercase.

Uploaded by

umamucheli34
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Naming conventions in java

===========================
In java uppercase letters will consider as different and lowercase letters will
consider as different that's why we consider Java is a case sensitive programming.

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

ex:
classes
interfaces
variables
methods
keywords
packages
constants

classes
---------
In java , a class must and should starts with uppercase letter and if it contains
multiple words then each inner word starts with initcap.
ex:
Predefined classes Userdefined classes
----------------- -------------------
System Test
File ExampleApp
FileWriter DemoApp
BufferedReader QualityThought
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 starts with initcap.

ex:
predefined interfaces Userdefined interfaces
------------------- ---------------------
Serializable ITest
Enumeration IDemoApp
ListIterator IExampleApp
Runnable IQualityThought
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 starts with initcap.
ex:
predefined variables userdefined variables
------------------ --------------------
out empId
in studName
err deptNo
length salary
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 starts with initcap.

ex:
predefined methods userdefined methods
------------------- -----------------
getClass() getDetails()
setName() setInfo()
getPriority() calculateBillAmt()
hashCode() getEmployeeDetails()
toString() and etc.
and etc.

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

ex:
predefined keywords
-------------------
if, else , switch, do , while, for , public , static and etc.

packages
--------
In java, all packages we need to write under lower case letters only.

ex:
predefined packages userdefined packages
------------------ ------------------
java.lang (default pkg) com.google.www
java.io com.ihub.www
java.time com.qt.www
java.util and etc.
java.util.stream
java.text
java.sql
javax.servlet
and etc.

constants
----------
In java , all constants we need to declare in uppercase letters only.
ex:
predefined constants userdefined constants
----------------- --------------------
MAX_PRIORITY LIMIT
MIN_PRIORITY IHUB_TALENT
MAX_VALUE and etc.
MIN_VALUE
and etc.

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

Q)Which package is a default package in java?

java.lang is a default package in java.


Q)How many classes are there in java?

Java 7 ------ 4024 classes


Java 8 ------ 4240 classes
Java 9 ------ 6005 classes
Java 10 ------ 6002 classes

Q)What is package ?

Package is a collection of classes and interfaces.

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

2) Interface : IQualityThought

3) Variable : qualityThought

4) Method : qualityThought()

5) package : com.qualitythought.www

6) Constant : QUALITYTHOUGHT / QUALITY_THOUGHT

You might also like