SlideShare a Scribd company logo
1 of 15
CORE
JAVA
CONCEPTS
Comments are almost like C++
The javadoc program generates HTML API
documentation from the “javadoc” style comments in
your code.
/* This kind comment can span multiple lines */
// This kind is of to the end of the line
/* This kind of comment is a special
* ‘javadoc’ style comment
*/
JAVA Classes
• The class is the fundamental concept in JAVA (and other
OOPLs)
• A class describes some data object(s), and the
operations (or methods) that can be applied to those
objects
• Every object and method in Java belongs to a class
• Classes have data (fields) and code (methods) and
classes (member classes or inner classes)
• Static methods and fields belong to the class itself
• Others belong to instances
An example of a class
class Person {
String name;
int age;
Variabl
e
Metho
d
void birthday ( )
{
age++;
System.out.println (name + '
is now ' + age);
}
}
Scopin
gAs in C/C++, scope is determined by the placement of curly braces {}.
A variable defined within a scope is available only to the end of that scope.
{ int x = 12;
/* only x available */
{ int q = 96;
/* both x and q available
*/
}
/* only x available */
/* q “out of scope” */
}
{ int x = 12;
{ int x = 96; /* illegal */
}
}
This is ok in C/C++ but not in Java.
Scope of Objects
• Java objects don’t have the same lifetimes as
primitives.
• When you create a Java object using new, it
hangs around past the end of the scope.
• Here, the scope of name s is delimited by the
{}s but the String object hangs around until
GC’d
{
String s = new String("a string");
} /* end of scope */
The static
keyword
• Java methods and variables can be declared static
• These exist independent of any object
• This means that a Class’s
– static methods can be called even if no objects of that
class have been created and
– static data is “shared” by all instances (i.e., one rvalue
per class instead of one per instance
class StaticTest {static int i = 47;} StaticTest st1 = new StaticTest();
StaticTest st2 = new StaticTest();
// st1.i == st2.I == 47 StaticTest.i++; // or st1.I++ or st2.I++
// st1.i == st2.I == 48
TIB Academy
Exampl
epublic class Circle {
// A class field
public static final double
PI= 3.14159; constant
// A class method: just
compute a value
// A useful
based on the
public static double
radiansToDegrees(double rads) { return rads *
180 / PI;
}// An instance field
public double r;
circle
// Two methodswhich
an object
// The radius of the
operate on
{
the instance
// Compute
fields of
the area of
public double
the circle
return PI *
area()
r * r;}
public double circumference() { // Compute the
circumference of the circle
return 2 * PI * r;
}
}
Array Operations
• Subscripts always start at 0 as in C
• Subscript checking is done
automatically
• Certain operations are defined on arrays
of objects, as for other classes
– e.g. myArray.length == 5
An array is an object
• Person mary = new Person ( );
• int myArray[ ] = new
] = {1, 4, 9,
int[5];
• int myArray[ 25};
• String Languages [ ] = {"Prolog", "Java"};
• Since arrays are objects they are allocated dynamically
• Arrays, like all objects, are subject to garbage collection
when no more references remain
– so fewer memory leaks
– Java doesn’t have pointers!
Example
Programs
Echo.jav
a
C:UMBC331java>
•
•
•
•
•
•
•
•
•
C:UMBC331java>type echo.java
// This is the Echo example from the Sun tutorial
class echo {
public static void main(String args[])
{ for (int i=0; i < args.length; i++) {
System.out.println( args[i] );
}
}
}
•
•
•
•
•
C:UMBC331java>javac echo.java
C:UMBC331java>java echo this is pretty silly
this
is pretty silly
TIB Academy
Factorial
Example/* This program computes the factorial of a number
*/
public class Factorial {
public static void
main(String[] args) { here
int input =
Integer.parseInt(args[0]); input
double result =
factorial(input); factorial
System.out.println(result); result
}
ends here
public static double
factorial(int x) { computes x!
// Define a class
// The program
starts
// Get the user's
// Compute the
// Print out the
// The main() method
// This method
initial value
while(x > 1) { // Loop until x equals
// multiply byxfact = fact * x;
each time
x = x - 1;
decrement x
}
// and then
// Jump back to the
if (x < 0) // Check for bad input
return 0.0; // if bad, return 0
double fact = 1.0; // Begin with an
Constructor
s• Classes should define one or more methods to create or
construct instances of the class
• Their name is the same as the class name
– note deviation from convention that methods begin with
lower case
• Constructors are differentiated by the number and types
of their arguments
– An example of overloading
• If you don’t define a constructor, a default one will be
created.
• Constructors automatically invoke the zero argument
constructor of their superclass when they begin (note that
this yields a recursive process!)
Methods, arguments and return
values
•Java methods are like C/C++ functions. General case:
returnType methodName ( arg1, arg2, … argN)
{
methodBody
}
The return keyword exits a method optionally with a value int
storage(String s) {return s.length() *
2;} boolean flag() { return true; }
float naturalLogBase() { return 2.718f; }
void nothing() { return; }
void nothing2() {}

More Related Content

What's hot

Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introductionSohanur63
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and objectFajar Baskoro
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword pptVinod Kumar
 
Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods javaPadma Kannan
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Javakjkleindorfer
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Javabackdoor
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in javaAtul Sehdev
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Conceptsmdfkhan625
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in JavaRavi_Kant_Sahu
 
Java basic tutorial
Java basic tutorialJava basic tutorial
Java basic tutorialBui Kiet
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member FunctionsMOHIT AGARWAL
 

What's hot (20)

Java class,object,method introduction
Java class,object,method introductionJava class,object,method introduction
Java class,object,method introduction
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
 
Object and class
Object and classObject and class
Object and class
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Classes and objects in java
Classes and objects in javaClasses and objects in java
Classes and objects in java
 
Classes,object and methods java
Classes,object and methods javaClasses,object and methods java
Classes,object and methods java
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Week9 Intro to classes and objects in Java
Week9 Intro to classes and objects in JavaWeek9 Intro to classes and objects in Java
Week9 Intro to classes and objects in Java
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
ITFT-Classes and object in java
ITFT-Classes and object in javaITFT-Classes and object in java
ITFT-Classes and object in java
 
Java02
Java02Java02
Java02
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java OO Revisited
Java OO RevisitedJava OO Revisited
Java OO Revisited
 
Ch03
Ch03Ch03
Ch03
 
Class or Object
Class or ObjectClass or Object
Class or Object
 
Core Java Concepts
Core Java ConceptsCore Java Concepts
Core Java Concepts
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Java basic tutorial
Java basic tutorialJava basic tutorial
Java basic tutorial
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 

Similar to Best Core Java Training In Bangalore

Core java concepts
Core java concepts Core java concepts
Core java concepts javeed_mhd
 
Java Basics
Java BasicsJava Basics
Java BasicsF K
 
Java assignment help
Java assignment helpJava assignment help
Java assignment helpJacob William
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java conceptsChikugehlot
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructorShivam Singhal
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.Tarunsingh198
 
Java tutorials
Java tutorialsJava tutorials
Java tutorialssaryu2011
 
JavaTutorials.ppt
JavaTutorials.pptJavaTutorials.ppt
JavaTutorials.pptKhizar40
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptxEpsiba1
 
OOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingOOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingPurvik Rana
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
Pi j2.2 classes
Pi j2.2 classesPi j2.2 classes
Pi j2.2 classesmcollison
 

Similar to Best Core Java Training In Bangalore (20)

Core java concepts
Core java concepts Core java concepts
Core java concepts
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java concepts
 
Java
JavaJava
Java
 
Java assignment help
Java assignment helpJava assignment help
Java assignment help
 
Java
JavaJava
Java
 
Core java concepts
Core java conceptsCore java concepts
Core java concepts
 
Core java concepts
Core    java  conceptsCore    java  concepts
Core java concepts
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Java Programming - 04 object oriented in java
Java Programming - 04 object oriented in javaJava Programming - 04 object oriented in java
Java Programming - 04 object oriented in java
 
JavaTutorials.ppt
JavaTutorials.pptJavaTutorials.ppt
JavaTutorials.ppt
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 
OOPs Concepts - Android Programming
OOPs Concepts - Android ProgrammingOOPs Concepts - Android Programming
OOPs Concepts - Android Programming
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Java Basic day-2
Java Basic day-2Java Basic day-2
Java Basic day-2
 
Class introduction in java
Class introduction in javaClass introduction in java
Class introduction in java
 
Pi j2.2 classes
Pi j2.2 classesPi j2.2 classes
Pi j2.2 classes
 

More from rajkamaltibacademy

Informatica Training Tutorial
Informatica Training Tutorial Informatica Training Tutorial
Informatica Training Tutorial rajkamaltibacademy
 
AWS Training Tutorial for Freshers
AWS Training Tutorial for FreshersAWS Training Tutorial for Freshers
AWS Training Tutorial for Freshersrajkamaltibacademy
 
CCNA Training Tutorial in bangaore
CCNA Training Tutorial in bangaoreCCNA Training Tutorial in bangaore
CCNA Training Tutorial in bangaorerajkamaltibacademy
 
Django Training Tutorial in Bangalore
Django Training Tutorial in BangaloreDjango Training Tutorial in Bangalore
Django Training Tutorial in Bangalorerajkamaltibacademy
 
Python Training Tutorial for Frreshers
Python Training Tutorial for FrreshersPython Training Tutorial for Frreshers
Python Training Tutorial for Frreshersrajkamaltibacademy
 
Oracle Training Tutorial for Beginners
Oracle Training Tutorial for BeginnersOracle Training Tutorial for Beginners
Oracle Training Tutorial for Beginnersrajkamaltibacademy
 
Mongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in BangaloreMongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in Bangalorerajkamaltibacademy
 
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experiencedrajkamaltibacademy
 
Teradata Tutorial for Beginners
Teradata Tutorial for BeginnersTeradata Tutorial for Beginners
Teradata Tutorial for Beginnersrajkamaltibacademy
 
R Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB AcademyR Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB Academyrajkamaltibacademy
 
Selenium tutorial to Beginners
Selenium tutorial to BeginnersSelenium tutorial to Beginners
Selenium tutorial to Beginnersrajkamaltibacademy
 
Angularjs Tutorial for Beginners
Angularjs Tutorial for BeginnersAngularjs Tutorial for Beginners
Angularjs Tutorial for Beginnersrajkamaltibacademy
 
Hadoop Training Tutorial for Freshers
Hadoop Training Tutorial for FreshersHadoop Training Tutorial for Freshers
Hadoop Training Tutorial for Freshersrajkamaltibacademy
 

More from rajkamaltibacademy (16)

Informatica Training Tutorial
Informatica Training Tutorial Informatica Training Tutorial
Informatica Training Tutorial
 
AWS Training Tutorial for Freshers
AWS Training Tutorial for FreshersAWS Training Tutorial for Freshers
AWS Training Tutorial for Freshers
 
.Net Training Tutorial
.Net Training Tutorial.Net Training Tutorial
.Net Training Tutorial
 
CCNA Training Tutorial in bangaore
CCNA Training Tutorial in bangaoreCCNA Training Tutorial in bangaore
CCNA Training Tutorial in bangaore
 
Django Training Tutorial in Bangalore
Django Training Tutorial in BangaloreDjango Training Tutorial in Bangalore
Django Training Tutorial in Bangalore
 
Python Training Tutorial for Frreshers
Python Training Tutorial for FrreshersPython Training Tutorial for Frreshers
Python Training Tutorial for Frreshers
 
Oracle Training Tutorial for Beginners
Oracle Training Tutorial for BeginnersOracle Training Tutorial for Beginners
Oracle Training Tutorial for Beginners
 
Mongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in BangaloreMongodb Training Tutorial in Bangalore
Mongodb Training Tutorial in Bangalore
 
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
 
Python Tutorial for Beginner
Python Tutorial for BeginnerPython Tutorial for Beginner
Python Tutorial for Beginner
 
Teradata Tutorial for Beginners
Teradata Tutorial for BeginnersTeradata Tutorial for Beginners
Teradata Tutorial for Beginners
 
R Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB AcademyR Programming Tutorial for Beginners - -TIB Academy
R Programming Tutorial for Beginners - -TIB Academy
 
Selenium tutorial to Beginners
Selenium tutorial to BeginnersSelenium tutorial to Beginners
Selenium tutorial to Beginners
 
Angularjs Tutorial for Beginners
Angularjs Tutorial for BeginnersAngularjs Tutorial for Beginners
Angularjs Tutorial for Beginners
 
Hadoop Training Tutorial for Freshers
Hadoop Training Tutorial for FreshersHadoop Training Tutorial for Freshers
Hadoop Training Tutorial for Freshers
 
Python Tutorial for Beginner
Python Tutorial for BeginnerPython Tutorial for Beginner
Python Tutorial for Beginner
 

Recently uploaded

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 

Recently uploaded (20)

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 

Best Core Java Training In Bangalore

  • 2. Comments are almost like C++ The javadoc program generates HTML API documentation from the “javadoc” style comments in your code. /* This kind comment can span multiple lines */ // This kind is of to the end of the line /* This kind of comment is a special * ‘javadoc’ style comment */
  • 3. JAVA Classes • The class is the fundamental concept in JAVA (and other OOPLs) • A class describes some data object(s), and the operations (or methods) that can be applied to those objects • Every object and method in Java belongs to a class • Classes have data (fields) and code (methods) and classes (member classes or inner classes) • Static methods and fields belong to the class itself • Others belong to instances
  • 4. An example of a class class Person { String name; int age; Variabl e Metho d void birthday ( ) { age++; System.out.println (name + ' is now ' + age); } }
  • 5. Scopin gAs in C/C++, scope is determined by the placement of curly braces {}. A variable defined within a scope is available only to the end of that scope. { int x = 12; /* only x available */ { int q = 96; /* both x and q available */ } /* only x available */ /* q “out of scope” */ } { int x = 12; { int x = 96; /* illegal */ } } This is ok in C/C++ but not in Java.
  • 6. Scope of Objects • Java objects don’t have the same lifetimes as primitives. • When you create a Java object using new, it hangs around past the end of the scope. • Here, the scope of name s is delimited by the {}s but the String object hangs around until GC’d { String s = new String("a string"); } /* end of scope */
  • 7. The static keyword • Java methods and variables can be declared static • These exist independent of any object • This means that a Class’s – static methods can be called even if no objects of that class have been created and – static data is “shared” by all instances (i.e., one rvalue per class instead of one per instance class StaticTest {static int i = 47;} StaticTest st1 = new StaticTest(); StaticTest st2 = new StaticTest(); // st1.i == st2.I == 47 StaticTest.i++; // or st1.I++ or st2.I++ // st1.i == st2.I == 48
  • 8. TIB Academy Exampl epublic class Circle { // A class field public static final double PI= 3.14159; constant // A class method: just compute a value // A useful based on the public static double radiansToDegrees(double rads) { return rads * 180 / PI; }// An instance field public double r; circle // Two methodswhich an object // The radius of the operate on { the instance // Compute fields of the area of public double the circle return PI * area() r * r;} public double circumference() { // Compute the circumference of the circle return 2 * PI * r; } }
  • 9. Array Operations • Subscripts always start at 0 as in C • Subscript checking is done automatically • Certain operations are defined on arrays of objects, as for other classes – e.g. myArray.length == 5
  • 10. An array is an object • Person mary = new Person ( ); • int myArray[ ] = new ] = {1, 4, 9, int[5]; • int myArray[ 25}; • String Languages [ ] = {"Prolog", "Java"}; • Since arrays are objects they are allocated dynamically • Arrays, like all objects, are subject to garbage collection when no more references remain – so fewer memory leaks – Java doesn’t have pointers!
  • 12. Echo.jav a C:UMBC331java> • • • • • • • • • C:UMBC331java>type echo.java // This is the Echo example from the Sun tutorial class echo { public static void main(String args[]) { for (int i=0; i < args.length; i++) { System.out.println( args[i] ); } } } • • • • • C:UMBC331java>javac echo.java C:UMBC331java>java echo this is pretty silly this is pretty silly
  • 13. TIB Academy Factorial Example/* This program computes the factorial of a number */ public class Factorial { public static void main(String[] args) { here int input = Integer.parseInt(args[0]); input double result = factorial(input); factorial System.out.println(result); result } ends here public static double factorial(int x) { computes x! // Define a class // The program starts // Get the user's // Compute the // Print out the // The main() method // This method initial value while(x > 1) { // Loop until x equals // multiply byxfact = fact * x; each time x = x - 1; decrement x } // and then // Jump back to the if (x < 0) // Check for bad input return 0.0; // if bad, return 0 double fact = 1.0; // Begin with an
  • 14. Constructor s• Classes should define one or more methods to create or construct instances of the class • Their name is the same as the class name – note deviation from convention that methods begin with lower case • Constructors are differentiated by the number and types of their arguments – An example of overloading • If you don’t define a constructor, a default one will be created. • Constructors automatically invoke the zero argument constructor of their superclass when they begin (note that this yields a recursive process!)
  • 15. Methods, arguments and return values •Java methods are like C/C++ functions. General case: returnType methodName ( arg1, arg2, … argN) { methodBody } The return keyword exits a method optionally with a value int storage(String s) {return s.length() * 2;} boolean flag() { return true; } float naturalLogBase() { return 2.718f; } void nothing() { return; } void nothing2() {}