1 Core java
2 Java is an object oriented programming language
3 OOPs: class, object, polymorphism, inheritance , constructor
4 It is an open source tool
5 It is a platform independent tool
6 This programming language is used for designing and for developing applications
7 Which is developed by Games goslin 1994 by microsystem
9 Structured programming : c programming ( class. Object)
10 Oriented based :vb, vbscript, python (class/object)
11 Object oriented programming language (c#, java, python , .net)
12 Features of java :
13
14 It is an open source tool
15 It is a platform independent tool
16 It is a multi threading ( parallel we can run multiple tasks )
17 3 components :
18 1) JDK: java development kit : script ( applications)
19 2) JRE : java run time Environment (compilation)
20 3) JVM : java virtual machine
21
22 It converts the English language into bytecode
23
24 1) Core java : designing /developing ( functions and methods) /testing( test script)
25 2) Advance java :front end as well as backend
26 Environment :
27 Notepad, eclipse, Intelli j ,visual studio
28 Eclipse : create a project / package /class
29 Class
30 Object: defines the state and behaviour of the program
31 State: properties of object
32 Bevaviour : functionality of the object
33
34 Pen : color , height , width , mD, brand
35 Paper, board,
36 Collection of object : class
37 Combination of data member and member function
38 Data member : the variables which are declared outside the method and inside the class
39 Member function the function which is declared inside the class
40
41 Class test
42 {
43 Int a, int b; =============data members
44 Public void add()=============member function
45 {
46 }
47 Class Test/test
48 Rules for specifying class Name
49 1) The class name can have either upper case of lower case
50 2) It cannot start with numbers
51 3) It can accept special symbol like _
52 Note 1:
53 To make a comment for a single line in java is : //
54 To make comment for multiple lines in java we use : /* and ends with */
55 To print a statement in java we use : [Link]();
56 Variable :
57 Which holds a data ( int, float, double, long, short, ch, string)
58 The values which changes during run time process
59 Ex: a=10;
60 Note: for assigning a value to a variable, there should be a data types
61 Ex:
62 Datatype variable =value;
63 Int a=10;
64 Rules of a variable :
65 1) No spaces are accepted for assigning a value to variable
66 2) The variable declaration should not start with values
67 3) It can start with _underscore at the beginning as well as at the end of the variable
68 declaration
69 4) No special symbols are accepted for declaration
70
71 Data type: the type of data which we are assigning to variable , the compiler should
72 Understand what kind of data for which variable we are assigning
73 There are two types of data types
74 1) Primitive data type: values (byte , Boolean ,int, char, string. Long , short, float, double)
75 2) Non primitive data type ( arrays, functions, methods, inheritances, hashtable collections)
76
77 Byte : 1 byte : -128 to 127
78 Int 4 bytes : -32768 to 32767
79 Float : -10.0f; ( literals) after decimal : 7 values
80 Double : -10.0000000000; after decimal : 15 values
81 Long : -2189,898,90,90 to 2189, 898,89
82 Long lg=-2189l;
83
84 package Java_Programming;
85
86 public class _testing_java {
87
88 public static void main(String[] args) {
89 // TODO Auto-generated method stub
90
91 //variable
92 //byte:
93 byte by=127; byte by1=-123;
94 [Link](by+by1);
95
96
97 int a1=33000;
98 //[Link](a1);
99 int a2=-31000;
100 [Link](a1+a2);
101
102
103 short sh=3535;
104 [Link](sh);
105 long lg=464545909989898l;
106 [Link](lg);
107 float f1=-90.000f;
108 [Link](f1);
109 double d1=-90.90909090909090909090;
110 [Link](d1);
111
112 String name="balakrishna";
113 String name1="kumar";
114 [Link](name+" " +name1);
115
116
117
118
119
120
121
122
123
124
125
126 }
127
128 }
129
130
131 Example Strings:
132
133 //String name='kumar';//invalid
134 //char ch3 ='abc';
135 //[Link](ch3)
136
137 String abc="a";[Link](abc);
138
139 Boolean res=10>20;
140 [Link](res);
141
142
143 Operators in java
144
145 Arithmetic operator: +,-,/,*,%
Operator Example Description
+ X+y Adding two values
- x-y Subtractiion from two values
/ x/y Division of two values
% X%y Remainder from the result
X*y Multiplication of two values
146
147 Three approaches for declaring the values to integer :
148 //int a=10; int b=20;
149 // int a,b; a=20; b=30;
150 int a=10,b=20,c=30;
151 example
152 int a=10,b=20;
153 //[Link](a+b);
154 [Link]("addition of two values :"+(a+b));
155 [Link]("subtraction of two values :"+(b-a));
156 [Link]("division of two values :"+(b/a));
157 [Link]("multiplication of two values :"+(a*b));
158 [Link]("modulus of two values :"+(b%a));
159
160 Logical operator : And Or Not
161 And : &&
162 Or : ||
163 Not : !
Operator Example Description
&& x>y && x>z If both conditions are satisfied
then the result will be true
|| x>y || x>z If any one the condition is true
then the result will be true
! X!=y Bsed on the condition the
result should be displayed as
true of false
164
165 int a=10,b=20,c=30;
166 //[Link](a+b);
167 [Link]("And Operator :"+((a<b)&&(b>c)));//false
168 [Link]("Or Operator :"+((a>b)||(b<c)));//true
169 [Link]("Not Operator :"+(a!=b));
170
X Y X &&y X||y !x !y
True True True True False False
True False False True False True
False True False True True False
False False False False True True
171
172 Boolean Operator :
173 boolean res=10>20;
174 [Link](res);
175
176 boolean res1=30<20;
177 [Link](res1);
178
179 Assignment operators :+=,-=,*=,/=,%=
180 Conditional operator /ternary operator : exp ?res1:res2;
181 Increment and decrement operators : ++a, a++, --b, b--;
182
183
184
185
186