Strategies for Landing an Oracle DBA Job as a Fresher
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.