SlideShare una empresa de Scribd logo
1 de 9
Nibble MATRIX Summer Training First day.
Environment Setting
Select Start -> Computer -> System Properties -> Advanced system settings ->
Advanced-> environment variable-> system variable ->path
Variable name= Path
Variable value= ; C:Program FilesJavajdk1.6.0_02bin;.
Ok and OK
Select
Java:
java is an object oriented, internet programming languge .
Its main feature is
1-plateform independent on machine
2- security
there are two tools which is for compliling and running java programs
javac - it is compiler which converst java source code to byte code ie.class file. This byte
code is standard for all platforms, machines or operating systems.
java - this is interpreter. this interprets the .class file based on a particular platform and
excutes them.e jvm -> java virtual machine comes into play. jvm for windows will be
different from jvm for solarais or linux . but all the jvm take the same byte code and
executes them in that platform.
Source code -> javac ->Universal byte code
Universal byte ->jvm/java -> execute them on a particular machine.
Syntex Of Defining Class:
Class Identifier
{
Member definition
}
/// First Pgm:-
public class Add {
void Addition(int a ,int b)
{
int c=a+b;
System.out.println("Sum of 2 number="+c);
}
public static void main(String[] args) {
Add obj=new Add();
obj.Addition(10, 20);
}
}
Steps to
//Run java pgm
// javac Add.java
Java Add
Naming Convension in Java:
Class: 1st letter of each world of class is capital
example: Welcome , ArrayIndexOutOfBoundException
Method: ist letter of each word except first world is capital
Example:- nextInt() , nextLine()
Keywords:-
Keywords are reserved identifiers that are predefined in the language and cannot
be used to denote other entities. All the keywords are in lowercase, and incorrect
usage results in compilation errors.
Identifiers :-
In Java an identifier is composed of a sequence of characters, where each character can be
either a letter, a digit, a connecting punctuation (such as underscore _), or any currency symbol
(such as $, ¢, ¥, or £). Identifiers can be used to denote classes, methods,
variables, and labels
Examples of Legal Identifiers:
number, Number, sum_$, bingo, $$_100,
Examples of Illegal Identifiers:
48chevy, all@hands, grand-sum
Lifetime of Variables:- is, the time a variable is accessible during execution, its
determined by the context in which it is declared
There are context of variable-
Instance variables :- members of a class and created for each object of the class
Static variables :- also members of a class, but not created for any object of the class and,
therefore, belong only to the class
Local variables :- declared in methods and in blocks and created for each execution of the
method or block
Default Values :-
Data Type Default Value Default data type
boolean false
char 'u0000'
Integer (byte, short, int, long) 0L for long, 0 for others Int
and can be specified by long by
appending the suffix (L or l)
Floating-point (float, double) 0.0F or 0.0D double but it can be explicitly
designated by appending the suffix
D (or d) to the value
Reference types null
type casting - to convert one cast to another cast
implicit type casting : auto - lower to higher
Example: byte b = 100;
int a = b; - valid
explicit type casting: user - higher to lower/ String to any.
int a = 200;
byte b = a; - error , need to explicit type casting
byte b = (byte)a;
Exmple:
public class Test {
void disp(){
int a = 300;
byte b = (byte)a;
System.out.println("value of b="+b);
}
public static void main(String[] args) {
Test obj=new Test();
obj.disp();
}
}
Ans= value of b=44
data types in java -
Data Byte
byte 1
short 2
int 4
long 8
float 4
double 8
char 2
boolean true / false
String to int
i- int a = Integer.parseInt(aa[0]);
ii- int a = Integer.valueOf(aa[0]).intValue();
String to float
i- float a = Float.parseFloat(aa[0]);
ii- float a = Float.valueOf(aa[0]).floatValue();
String to double
i- double a = Double.parseDouble(aa[0]);
ii- double a = Double.valueOf(aa[0]).doubleValue();
String to long
i- long a = Long.parseLong(aa[0]);
ii- long a = Long.valueOf(aa[0]).longValue();
Object creation in C++
int a; - var declare
Classname objname ;
ex -
C1 o; - default or no argument passing Constructor calling.
in java
Classname objname = new ClassConstructor();
ex -
C1 o = new C1(); - default or no argument passing Constructor
calling.
working with objects in java
Object var - before memory allocation
ClassName objname;
ex -
C1 o; - o is a kind of object var
Instance var - after memory allocation
objname = new ClassConstructor();
ex -
o = new C1(); - now o is is a kind of instance var.
a = 10; - now a is a initialize var
int a = 100; - declare + initialize
C1 o = new C1(); - object + instance
Ref object var - when one object hold the ref of another object
C1 o = new C1();
C1 n = o; - n hold the ref of o object.
new - operator , it is for -
* call the Constructor
* allocate memory for Object
* return ref of class for Object.
C1 o = new C1();
o.disp(); - C1 class disp.

Más contenido relacionado

La actualidad más candente

Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
Quick python reference
Quick python referenceQuick python reference
Quick python reference
Jayant Parida
 

La actualidad más candente (20)

Lecture 7 arrays
Lecture   7 arraysLecture   7 arrays
Lecture 7 arrays
 
C# programming
C# programming C# programming
C# programming
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Java Foundations: Methods
Java Foundations: MethodsJava Foundations: Methods
Java Foundations: Methods
 
Introduction to c ++ part -2
Introduction to c ++   part -2Introduction to c ++   part -2
Introduction to c ++ part -2
 
Operators
OperatorsOperators
Operators
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
Java ppt Gandhi Ravi (gandhiri@gmail.com)
Java ppt  Gandhi Ravi  (gandhiri@gmail.com)Java ppt  Gandhi Ravi  (gandhiri@gmail.com)
Java ppt Gandhi Ravi (gandhiri@gmail.com)
 
Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods Advanced Python : Static and Class Methods
Advanced Python : Static and Class Methods
 
Core java concepts
Core java concepts Core java concepts
Core java concepts
 
Python programming : Abstract classes interfaces
Python programming : Abstract classes interfacesPython programming : Abstract classes interfaces
Python programming : Abstract classes interfaces
 
Java Basic day-2
Java Basic day-2Java Basic day-2
Java Basic day-2
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
Java Foundations: Objects and Classes
Java Foundations: Objects and ClassesJava Foundations: Objects and Classes
Java Foundations: Objects and Classes
 
Quick python reference
Quick python referenceQuick python reference
Quick python reference
 
Python unit 3 m.sc cs
Python unit 3 m.sc csPython unit 3 m.sc cs
Python unit 3 m.sc cs
 
Interface
InterfaceInterface
Interface
 
11. java methods
11. java methods11. java methods
11. java methods
 

Destacado (13)

Ui vs ux
Ui vs uxUi vs ux
Ui vs ux
 
Unidades de medida
Unidades de medidaUnidades de medida
Unidades de medida
 
Living past chapter 4 government by ferry tanoto
Living past chapter 4 government by ferry tanotoLiving past chapter 4 government by ferry tanoto
Living past chapter 4 government by ferry tanoto
 
Database Oracle Basic
Database Oracle BasicDatabase Oracle Basic
Database Oracle Basic
 
Social networks analisys - github API
Social networks analisys - github APISocial networks analisys - github API
Social networks analisys - github API
 
Powerpoint
PowerpointPowerpoint
Powerpoint
 
Gretapeyran 2010 11-esercizio4
Gretapeyran 2010 11-esercizio4Gretapeyran 2010 11-esercizio4
Gretapeyran 2010 11-esercizio4
 
Gretapeyran 2010 11-esercizio4
Gretapeyran 2010 11-esercizio4Gretapeyran 2010 11-esercizio4
Gretapeyran 2010 11-esercizio4
 
Social networks analisys - github API
Social networks analisys - github APISocial networks analisys - github API
Social networks analisys - github API
 
Jvm
JvmJvm
Jvm
 
Smartphone Research - Nov 2010
Smartphone Research - Nov 2010Smartphone Research - Nov 2010
Smartphone Research - Nov 2010
 
Tcnicasdedibujoypintura2 110502060246-phpapp01
Tcnicasdedibujoypintura2 110502060246-phpapp01Tcnicasdedibujoypintura2 110502060246-phpapp01
Tcnicasdedibujoypintura2 110502060246-phpapp01
 
Oops Concept Java
Oops Concept JavaOops Concept Java
Oops Concept Java
 

Similar a Java Basic day-1

Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
Bharat17485
 

Similar a Java Basic day-1 (20)

java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
 
Identifiers, keywords and types
Identifiers, keywords and typesIdentifiers, keywords and types
Identifiers, keywords and types
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
 
Learning Java 1 – Introduction
Learning Java 1 – IntroductionLearning Java 1 – Introduction
Learning Java 1 – Introduction
 
Java Language fundamental
Java Language fundamentalJava Language fundamental
Java Language fundamental
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
 
Variables and Data Types
Variables and Data TypesVariables and Data Types
Variables and Data Types
 
Lecture 2 java.pdf
Lecture 2 java.pdfLecture 2 java.pdf
Lecture 2 java.pdf
 
Java
JavaJava
Java
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Java q ref 2018
Java q ref 2018Java q ref 2018
Java q ref 2018
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
Basic_Java_02.pptx
Basic_Java_02.pptxBasic_Java_02.pptx
Basic_Java_02.pptx
 
Stream Based Input Output
Stream Based Input OutputStream Based Input Output
Stream Based Input Output
 
First fare 2010 java-introduction
First fare 2010 java-introductionFirst fare 2010 java-introduction
First fare 2010 java-introduction
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Java Basic day-1

  • 1. Nibble MATRIX Summer Training First day. Environment Setting Select Start -> Computer -> System Properties -> Advanced system settings -> Advanced-> environment variable-> system variable ->path Variable name= Path Variable value= ; C:Program FilesJavajdk1.6.0_02bin;. Ok and OK Select
  • 2. Java: java is an object oriented, internet programming languge . Its main feature is 1-plateform independent on machine 2- security there are two tools which is for compliling and running java programs javac - it is compiler which converst java source code to byte code ie.class file. This byte code is standard for all platforms, machines or operating systems. java - this is interpreter. this interprets the .class file based on a particular platform and excutes them.e jvm -> java virtual machine comes into play. jvm for windows will be different from jvm for solarais or linux . but all the jvm take the same byte code and executes them in that platform. Source code -> javac ->Universal byte code Universal byte ->jvm/java -> execute them on a particular machine. Syntex Of Defining Class: Class Identifier { Member definition }
  • 3. /// First Pgm:- public class Add { void Addition(int a ,int b) { int c=a+b; System.out.println("Sum of 2 number="+c); } public static void main(String[] args) { Add obj=new Add(); obj.Addition(10, 20); } } Steps to //Run java pgm // javac Add.java Java Add Naming Convension in Java: Class: 1st letter of each world of class is capital example: Welcome , ArrayIndexOutOfBoundException Method: ist letter of each word except first world is capital Example:- nextInt() , nextLine()
  • 4. Keywords:- Keywords are reserved identifiers that are predefined in the language and cannot be used to denote other entities. All the keywords are in lowercase, and incorrect usage results in compilation errors. Identifiers :- In Java an identifier is composed of a sequence of characters, where each character can be either a letter, a digit, a connecting punctuation (such as underscore _), or any currency symbol (such as $, ¢, ¥, or £). Identifiers can be used to denote classes, methods, variables, and labels Examples of Legal Identifiers: number, Number, sum_$, bingo, $$_100, Examples of Illegal Identifiers: 48chevy, all@hands, grand-sum
  • 5.
  • 6. Lifetime of Variables:- is, the time a variable is accessible during execution, its determined by the context in which it is declared There are context of variable- Instance variables :- members of a class and created for each object of the class Static variables :- also members of a class, but not created for any object of the class and, therefore, belong only to the class Local variables :- declared in methods and in blocks and created for each execution of the method or block Default Values :- Data Type Default Value Default data type boolean false char 'u0000' Integer (byte, short, int, long) 0L for long, 0 for others Int and can be specified by long by appending the suffix (L or l) Floating-point (float, double) 0.0F or 0.0D double but it can be explicitly designated by appending the suffix D (or d) to the value Reference types null
  • 7. type casting - to convert one cast to another cast implicit type casting : auto - lower to higher Example: byte b = 100; int a = b; - valid explicit type casting: user - higher to lower/ String to any. int a = 200; byte b = a; - error , need to explicit type casting byte b = (byte)a; Exmple: public class Test { void disp(){ int a = 300; byte b = (byte)a; System.out.println("value of b="+b); } public static void main(String[] args) { Test obj=new Test(); obj.disp(); } } Ans= value of b=44 data types in java - Data Byte byte 1 short 2 int 4 long 8 float 4 double 8 char 2 boolean true / false
  • 8. String to int i- int a = Integer.parseInt(aa[0]); ii- int a = Integer.valueOf(aa[0]).intValue(); String to float i- float a = Float.parseFloat(aa[0]); ii- float a = Float.valueOf(aa[0]).floatValue(); String to double i- double a = Double.parseDouble(aa[0]); ii- double a = Double.valueOf(aa[0]).doubleValue(); String to long i- long a = Long.parseLong(aa[0]); ii- long a = Long.valueOf(aa[0]).longValue(); Object creation in C++ int a; - var declare Classname objname ; ex - C1 o; - default or no argument passing Constructor calling. in java Classname objname = new ClassConstructor(); ex - C1 o = new C1(); - default or no argument passing Constructor calling. working with objects in java Object var - before memory allocation ClassName objname; ex - C1 o; - o is a kind of object var
  • 9. Instance var - after memory allocation objname = new ClassConstructor(); ex - o = new C1(); - now o is is a kind of instance var. a = 10; - now a is a initialize var int a = 100; - declare + initialize C1 o = new C1(); - object + instance Ref object var - when one object hold the ref of another object C1 o = new C1(); C1 n = o; - n hold the ref of o object. new - operator , it is for - * call the Constructor * allocate memory for Object * return ref of class for Object. C1 o = new C1(); o.disp(); - C1 class disp.