SlideShare a Scribd company logo
1 of 7
www.p2cinfotech.com

+1-732-546-3607

Fundamental Classes
Overview of java.lang package Object
The package java.lang contains classes and interfaces that are essential to the Java
language. These include:
•

Object Class

•

Math Class

•

The wrapper classes

•

String

•

StringBuffer

•

StringTokenizer

java.lang (non-objectives)
 Cloneable : A class implements the Cloneable interface to indicate to the
clone method in class Object that it is legal for that method to make a field-forfield copy of instances of that class.

 SecurityManager : The security manager is an abstract class that allows
applications to implement a security policy.

 Exceptions : The class Exception and its subclasses are a form of Throwable
that indicates conditions that a reasonable application might want to catch.

 Errors : An Error is a subclass of Throwable that indicates serious problems
that a reasonable application should not try to catch. Most such errors are
abnormal conditions.

 ClassLoader : The class ClassLoader is an abstract class. Applications
implement subclasses of ClassLoader in order to extend the manner in which the
Java Virtual Machine dynamically loads classes.
www.p2cinfotech.com

+1-732-546-3607

java.lang.Object
Class Object is the root of the class hierarchy. Every class has Object as a
superclass. All objects, including arrays, implement the methods of this class.
 public boolean equals( Object object )
a) should be overrided
b) provides “deep” comparison
c) not the same as ==!
•
•

== checks to see if the two objects are actually the same object
equals() compares the relevant instance variables of the two
objects
 public String toString()
a)should be overrided
b) returns a textual representation of the object
c) useful for debugging

java.lang.Math :
The class Math contains methods for performing basic numeric operations
such as the elementary exponential, logarithm, square root, and trigonometric functions.





class is final
constructor is private
methods are static
public static final double E
•

as close as Java can get to e, the base of natural logarithms

 public static final double PI
•

as close as Java can get to pi, the ratio of the circumference of a circle to
its diameter
www.p2cinfotech.com

+1-732-546-3607

int, long, float, double
int, long, float, double

abs()
max(x1, x2)

int, long, float, double

min( x1, x2)

Returns absolute value
Returns the greater of x1
and x2
Returns the smaller of x1
and x2

 double ceil( double d )
• returns the smallest integer that is not less than d, and equal to a
mathematical integer
• double x = Math.ceil( 423.3267 ); x == 424.0;
 double floor( double d )
• returns the largest integer that is not greater than d, and equal to a
mathematical integer
• double x = Math.floor( 423.3267 ); x == 423.0;
 double random()
• returns a random number between 0.0 and 1.0
• java.util.Random has more functionality
 double sin( double d )
• returns the sine of d
 double cos( double d )
• returns the cosine of d
 double tan( double d )
• returns the tangent of d
 double sqrt( double d )
• returns the square root of d

java.lang Wrapper Classes
Wrapper class wraps (encloses) around a data type and gives it an object appearance.
Wherever, the data type is required as an object, this object can be used.
Wrapper classes include methods to unwrap the object and give back the
data type. It can be compared with a chocolate. The manufacturer wraps the chocolate
with some foil or paper to prevent from pollution. The user takes the chocolate, removes
and throws the wrapper and eats it.
www.p2cinfotech.com

Primitive Data Type
boolean
byte
char
short
int
long
float
double

+1-732-546-3607

Wrapper Class
Boolean
Byte
Character
Short
Integer
Long
Float
Double

 encapsulates a single, immutable value
 all wrapper classes can be constructed by passing the value to be wrapper to the
constructor
• double d = 453.2344;
• Double myDouble = new Double( d );
 can also pass Strings that represent the value to be wrapped (doesn’t work for
Character)
• Short myShort = new Short( “2453” );
• throws NumberFormatException
 the values can be extracted by calling XXXvalue() where XXX is the name of the
primitive type.
 wrapper classes useful for classes such as Vector, which only operates on
Objects

java.lang.String
The String class represents character strings. All string literals in Java programs, such
as "abc", are implemented as instances of this class.
Strings are constant; their values cannot be changed after they are
created. String buffers support mutable strings. Because String objects are immutable
they can be shared.
 uses 16-bit Unicode characters
 represents an immutable string
 Java programs have a pool of literals
• when a String literal is created, it is created in the pool
• if the value already exists, then the existing instance of String is
used
• both == and equals() work
www.p2cinfotech.com

Difference between equals() and ==
Example:1
String s1 = “test”;
String s2 = “test”;
s1 == s2; // returns true
s1.equals( s2 ); // returns true

Example:2
String s3 = “abc”;
String s4 = new String( s3 );
s3 == s4; // returns false
s3.equals( s4 ); // returns true

String methods:
•

char charAt( int index)

•

String concat( String addThis )

•

int compareTo( String otherString )

•

boolean endsWith( String suffix )

•

boolean equals( Object obj )

•

boolean equalsIgnoreCase( String s )

•

int indexOf( char c )

•

int lastIndexOf( char c )

•

int length()

•

String replace( char old, char new )

+1-732-546-3607
www.p2cinfotech.com

•

boolean startsWith( String prefix )

•

String substring( int startIndex )

•

String toLowerCase()

•

String toString()

•

String toUpperCase()

•

+1-732-546-3607

String trim()

java.lang.StringBuffer
A thread-safe, mutable sequence of characters. String Buffer represents a String which
can be modified and has a capacity which can grow dynamically. String buffers are safe
for use by multiple threads.
The methods are synchronized where necessary so that all the operations
on any particular instance behave as if they occur in some serial order that is consistent
with the order of the method calls made by each of the individual threads involved.
•

StringBuffer append( String s )

•

StringBuffer append( Object obj )

•

StringBuffer insert( int offset, String s )

•

StringBuffer reverse()

•

StringBuffer setCharAt( int offset, char c )

•

StringBuffer setLength( int newlength )

•

String toString()

java.lang.String Concatenation
•

Java has overloaded the + operator for Strings

•

a+b+c is interpreted as

new StringBuffer().append(a).append(b).append(c).toString()
www.p2cinfotech.com

+1-732-546-3607

StringTokenizer
The string tokenizer class allows an application to break a string into tokens. The
tokenization method is much simpler than the one used by the StreamTokenizer class.
The StringTokenizer methods do not distinguish among identifiers, numbers, and
quoted strings, nor do they recognize and skip comments.
 The set of delimiters (the characters that separate tokens) may be specified
either at creation time or on a per-token basis.
 An instance of StringTokenizer behaves in one of two ways, depending on
whether it was created with the returnTokens flag having the value true or false:
 If the flag is false, delimiter characters serve to separate tokens. A token is
a maximal sequence of consecutive characters that are not delimiters.
 If the flag is true, delimiter characters are considered to be tokens. A token
is either one delimiter character, or a maximal sequence of consecutive
characters that are not delimiters.

More Related Content

What's hot

EBS-OPM Costing.docx
EBS-OPM Costing.docxEBS-OPM Costing.docx
EBS-OPM Costing.docxMina Lotfy
 
Entity Relationship (ER) Model Questions
Entity Relationship (ER) Model QuestionsEntity Relationship (ER) Model Questions
Entity Relationship (ER) Model QuestionsMohd Tousif
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
Personalization Validate Po Quantity With PR
Personalization Validate Po Quantity With PRPersonalization Validate Po Quantity With PR
Personalization Validate Po Quantity With PRAhmed Elshayeb
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts Bharat Kalia
 
Oracle Fusion Employment Models
Oracle Fusion Employment ModelsOracle Fusion Employment Models
Oracle Fusion Employment ModelsFeras Ahmad
 
Calendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence managementCalendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence managementFeras Ahmad
 
basic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptxbasic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptxAnusha sivakumar
 
Bsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureBsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureRai University
 
Defining key flexfields
Defining key flexfieldsDefining key flexfields
Defining key flexfieldsrunjithrocking
 
Oracle Compensation Management
Oracle Compensation ManagementOracle Compensation Management
Oracle Compensation ManagementHussain Abbas
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programmingKamal Acharya
 
11 deployment diagrams
11 deployment diagrams11 deployment diagrams
11 deployment diagramsBaskarkncet
 

What's hot (20)

EBS-OPM Costing.docx
EBS-OPM Costing.docxEBS-OPM Costing.docx
EBS-OPM Costing.docx
 
Entity Relationship (ER) Model Questions
Entity Relationship (ER) Model QuestionsEntity Relationship (ER) Model Questions
Entity Relationship (ER) Model Questions
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Personalization Validate Po Quantity With PR
Personalization Validate Po Quantity With PRPersonalization Validate Po Quantity With PR
Personalization Validate Po Quantity With PR
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
Oracle Fusion Employment Models
Oracle Fusion Employment ModelsOracle Fusion Employment Models
Oracle Fusion Employment Models
 
This and Static Keyword
This and Static KeywordThis and Static Keyword
This and Static Keyword
 
Oracle forms personalization
Oracle forms personalizationOracle forms personalization
Oracle forms personalization
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
 
Calendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence managementCalendar working days and holidays for Oracle EBS R12 Absence management
Calendar working days and holidays for Oracle EBS R12 Absence management
 
basic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptxbasic structure of SQL FINAL.pptx
basic structure of SQL FINAL.pptx
 
Install base
Install baseInstall base
Install base
 
Bsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architectureBsc cs ii-dbms- u-ii-database system concepts and architecture
Bsc cs ii-dbms- u-ii-database system concepts and architecture
 
Defining key flexfields
Defining key flexfieldsDefining key flexfields
Defining key flexfields
 
09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
Sql fundamentals
Sql fundamentalsSql fundamentals
Sql fundamentals
 
Oracle Compensation Management
Oracle Compensation ManagementOracle Compensation Management
Oracle Compensation Management
 
R12 opm api
R12 opm apiR12 opm api
R12 opm api
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
11 deployment diagrams
11 deployment diagrams11 deployment diagrams
11 deployment diagrams
 

Viewers also liked

Short definitions of all testing types
Short definitions of all testing typesShort definitions of all testing types
Short definitions of all testing typesGaruda Trainings
 
Interview questions and answers for quality assurance
Interview questions and answers for quality assuranceInterview questions and answers for quality assurance
Interview questions and answers for quality assuranceGaruda Trainings
 
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
 
Yaazli International Hibernate Training
Yaazli International Hibernate TrainingYaazli International Hibernate Training
Yaazli International Hibernate TrainingArjun Sridhar U R
 
Non ieee dot net projects list
Non  ieee dot net projects list Non  ieee dot net projects list
Non ieee dot net projects list Mumbai Academisc
 
For Loops and Variables in Java
For Loops and Variables in JavaFor Loops and Variables in Java
For Loops and Variables in JavaPokequesthero
 
Yaazli International Web Project Workshop
Yaazli International Web Project WorkshopYaazli International Web Project Workshop
Yaazli International Web Project WorkshopArjun Sridhar U R
 
Yaazli International AngularJS 5 Training
Yaazli International AngularJS 5 TrainingYaazli International AngularJS 5 Training
Yaazli International AngularJS 5 TrainingArjun Sridhar U R
 
Yaazli International Spring Training
Yaazli International Spring Training Yaazli International Spring Training
Yaazli International Spring Training Arjun Sridhar U R
 

Viewers also liked (20)

Short definitions of all testing types
Short definitions of all testing typesShort definitions of all testing types
Short definitions of all testing types
 
SAP BI 7.0 Info Providers
SAP BI 7.0 Info ProvidersSAP BI 7.0 Info Providers
SAP BI 7.0 Info Providers
 
Interview questions and answers for quality assurance
Interview questions and answers for quality assuranceInterview questions and answers for quality assurance
Interview questions and answers for quality assurance
 
Top 14 qa interview tips
Top 14 qa interview tipsTop 14 qa interview tips
Top 14 qa interview tips
 
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
 
Yaazli International Hibernate Training
Yaazli International Hibernate TrainingYaazli International Hibernate Training
Yaazli International Hibernate Training
 
02basics
02basics02basics
02basics
 
Non ieee dot net projects list
Non  ieee dot net projects list Non  ieee dot net projects list
Non ieee dot net projects list
 
Exception handling in java
Exception handling in java Exception handling in java
Exception handling in java
 
Toolbarexample
ToolbarexampleToolbarexample
Toolbarexample
 
For Loops and Variables in Java
For Loops and Variables in JavaFor Loops and Variables in Java
For Loops and Variables in Java
 
Yaazli International Web Project Workshop
Yaazli International Web Project WorkshopYaazli International Web Project Workshop
Yaazli International Web Project Workshop
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Savr
SavrSavr
Savr
 
Java quick reference v2
Java quick reference v2Java quick reference v2
Java quick reference v2
 
Yaazli International AngularJS 5 Training
Yaazli International AngularJS 5 TrainingYaazli International AngularJS 5 Training
Yaazli International AngularJS 5 Training
 
Yaazli International Spring Training
Yaazli International Spring Training Yaazli International Spring Training
Yaazli International Spring Training
 
Core java online training
Core java online trainingCore java online training
Core java online training
 
09events
09events09events
09events
 
Singleton pattern
Singleton patternSingleton pattern
Singleton pattern
 

Similar to Fundamental classes in java

Similar to Fundamental classes in java (20)

Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Java
JavaJava
Java
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
Java String
Java String Java String
Java String
 
Java tutorial part 3
Java tutorial part 3Java tutorial part 3
Java tutorial part 3
 
Java Day-4
Java Day-4Java Day-4
Java Day-4
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
chapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptxchapter 1-overview of java programming.pptx
chapter 1-overview of java programming.pptx
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vector
 
Taxonomy of Scala
Taxonomy of ScalaTaxonomy of Scala
Taxonomy of Scala
 
Java
JavaJava
Java
 
Net framework
Net frameworkNet framework
Net framework
 
Learn ActionScript programming myassignmenthelp.net
Learn ActionScript programming myassignmenthelp.netLearn ActionScript programming myassignmenthelp.net
Learn ActionScript programming myassignmenthelp.net
 
Learning core java
Learning core javaLearning core java
Learning core java
 
ppt_on_java.pptx
ppt_on_java.pptxppt_on_java.pptx
ppt_on_java.pptx
 
Java R20 - UNIT-5.docx
Java R20 - UNIT-5.docxJava R20 - UNIT-5.docx
Java R20 - UNIT-5.docx
 
Java R20 - UNIT-5.pdf
Java R20 - UNIT-5.pdfJava R20 - UNIT-5.pdf
Java R20 - UNIT-5.pdf
 
Javasession6
Javasession6Javasession6
Javasession6
 
Java Tutorials
Java Tutorials Java Tutorials
Java Tutorials
 

More from Garuda Trainings

Software testing life cycle
Software testing life cycleSoftware testing life cycle
Software testing life cycleGaruda Trainings
 
Performance testing interview questions and answers
Performance testing interview questions and answersPerformance testing interview questions and answers
Performance testing interview questions and answersGaruda Trainings
 
Loadrunner interview questions and answers
Loadrunner interview questions and answersLoadrunner interview questions and answers
Loadrunner interview questions and answersGaruda Trainings
 
Business analysis interview question and answers
Business analysis interview question and answersBusiness analysis interview question and answers
Business analysis interview question and answersGaruda Trainings
 
Quality center interview questions and answers
Quality center interview questions and answersQuality center interview questions and answers
Quality center interview questions and answersGaruda Trainings
 
Software development life cycle
Software development life cycleSoftware development life cycle
Software development life cycleGaruda Trainings
 
Interview Questions and Answers for Java
Interview Questions and Answers for JavaInterview Questions and Answers for Java
Interview Questions and Answers for JavaGaruda Trainings
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobGaruda Trainings
 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineGaruda Trainings
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testingGaruda Trainings
 

More from Garuda Trainings (11)

Software testing life cycle
Software testing life cycleSoftware testing life cycle
Software testing life cycle
 
Performance testing interview questions and answers
Performance testing interview questions and answersPerformance testing interview questions and answers
Performance testing interview questions and answers
 
Loadrunner interview questions and answers
Loadrunner interview questions and answersLoadrunner interview questions and answers
Loadrunner interview questions and answers
 
Business analysis interview question and answers
Business analysis interview question and answersBusiness analysis interview question and answers
Business analysis interview question and answers
 
Quality center interview questions and answers
Quality center interview questions and answersQuality center interview questions and answers
Quality center interview questions and answers
 
Software development life cycle
Software development life cycleSoftware development life cycle
Software development life cycle
 
Interview Questions and Answers for Java
Interview Questions and Answers for JavaInterview Questions and Answers for Java
Interview Questions and Answers for Java
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a job
 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement online
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testing
 
SQL for ETL Testing
SQL for ETL TestingSQL for ETL Testing
SQL for ETL Testing
 

Recently uploaded

Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Celine George
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfmstarkes24
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxShibin Azad
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointELaRue0
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxjmorse8
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryEugene Lysak
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024CapitolTechU
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the lifeNitinDeodare
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPragya - UEM Kolkata Quiz Club
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesTechSoup
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Abhinav Gaur Kaptaan
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxCapitolTechU
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxCeline George
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security Services
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 

Fundamental classes in java

  • 1. www.p2cinfotech.com +1-732-546-3607 Fundamental Classes Overview of java.lang package Object The package java.lang contains classes and interfaces that are essential to the Java language. These include: • Object Class • Math Class • The wrapper classes • String • StringBuffer • StringTokenizer java.lang (non-objectives)  Cloneable : A class implements the Cloneable interface to indicate to the clone method in class Object that it is legal for that method to make a field-forfield copy of instances of that class.  SecurityManager : The security manager is an abstract class that allows applications to implement a security policy.  Exceptions : The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch.  Errors : An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions.  ClassLoader : The class ClassLoader is an abstract class. Applications implement subclasses of ClassLoader in order to extend the manner in which the Java Virtual Machine dynamically loads classes.
  • 2. www.p2cinfotech.com +1-732-546-3607 java.lang.Object Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class.  public boolean equals( Object object ) a) should be overrided b) provides “deep” comparison c) not the same as ==! • • == checks to see if the two objects are actually the same object equals() compares the relevant instance variables of the two objects  public String toString() a)should be overrided b) returns a textual representation of the object c) useful for debugging java.lang.Math : The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.     class is final constructor is private methods are static public static final double E • as close as Java can get to e, the base of natural logarithms  public static final double PI • as close as Java can get to pi, the ratio of the circumference of a circle to its diameter
  • 3. www.p2cinfotech.com +1-732-546-3607 int, long, float, double int, long, float, double abs() max(x1, x2) int, long, float, double min( x1, x2) Returns absolute value Returns the greater of x1 and x2 Returns the smaller of x1 and x2  double ceil( double d ) • returns the smallest integer that is not less than d, and equal to a mathematical integer • double x = Math.ceil( 423.3267 ); x == 424.0;  double floor( double d ) • returns the largest integer that is not greater than d, and equal to a mathematical integer • double x = Math.floor( 423.3267 ); x == 423.0;  double random() • returns a random number between 0.0 and 1.0 • java.util.Random has more functionality  double sin( double d ) • returns the sine of d  double cos( double d ) • returns the cosine of d  double tan( double d ) • returns the tangent of d  double sqrt( double d ) • returns the square root of d java.lang Wrapper Classes Wrapper class wraps (encloses) around a data type and gives it an object appearance. Wherever, the data type is required as an object, this object can be used. Wrapper classes include methods to unwrap the object and give back the data type. It can be compared with a chocolate. The manufacturer wraps the chocolate with some foil or paper to prevent from pollution. The user takes the chocolate, removes and throws the wrapper and eats it.
  • 4. www.p2cinfotech.com Primitive Data Type boolean byte char short int long float double +1-732-546-3607 Wrapper Class Boolean Byte Character Short Integer Long Float Double  encapsulates a single, immutable value  all wrapper classes can be constructed by passing the value to be wrapper to the constructor • double d = 453.2344; • Double myDouble = new Double( d );  can also pass Strings that represent the value to be wrapped (doesn’t work for Character) • Short myShort = new Short( “2453” ); • throws NumberFormatException  the values can be extracted by calling XXXvalue() where XXX is the name of the primitive type.  wrapper classes useful for classes such as Vector, which only operates on Objects java.lang.String The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared.  uses 16-bit Unicode characters  represents an immutable string  Java programs have a pool of literals • when a String literal is created, it is created in the pool • if the value already exists, then the existing instance of String is used • both == and equals() work
  • 5. www.p2cinfotech.com Difference between equals() and == Example:1 String s1 = “test”; String s2 = “test”; s1 == s2; // returns true s1.equals( s2 ); // returns true Example:2 String s3 = “abc”; String s4 = new String( s3 ); s3 == s4; // returns false s3.equals( s4 ); // returns true String methods: • char charAt( int index) • String concat( String addThis ) • int compareTo( String otherString ) • boolean endsWith( String suffix ) • boolean equals( Object obj ) • boolean equalsIgnoreCase( String s ) • int indexOf( char c ) • int lastIndexOf( char c ) • int length() • String replace( char old, char new ) +1-732-546-3607
  • 6. www.p2cinfotech.com • boolean startsWith( String prefix ) • String substring( int startIndex ) • String toLowerCase() • String toString() • String toUpperCase() • +1-732-546-3607 String trim() java.lang.StringBuffer A thread-safe, mutable sequence of characters. String Buffer represents a String which can be modified and has a capacity which can grow dynamically. String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved. • StringBuffer append( String s ) • StringBuffer append( Object obj ) • StringBuffer insert( int offset, String s ) • StringBuffer reverse() • StringBuffer setCharAt( int offset, char c ) • StringBuffer setLength( int newlength ) • String toString() java.lang.String Concatenation • Java has overloaded the + operator for Strings • a+b+c is interpreted as new StringBuffer().append(a).append(b).append(c).toString()
  • 7. www.p2cinfotech.com +1-732-546-3607 StringTokenizer The string tokenizer class allows an application to break a string into tokens. The tokenization method is much simpler than the one used by the StreamTokenizer class. The StringTokenizer methods do not distinguish among identifiers, numbers, and quoted strings, nor do they recognize and skip comments.  The set of delimiters (the characters that separate tokens) may be specified either at creation time or on a per-token basis.  An instance of StringTokenizer behaves in one of two ways, depending on whether it was created with the returnTokens flag having the value true or false:  If the flag is false, delimiter characters serve to separate tokens. A token is a maximal sequence of consecutive characters that are not delimiters.  If the flag is true, delimiter characters are considered to be tokens. A token is either one delimiter character, or a maximal sequence of consecutive characters that are not delimiters.