Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Basics of java
Description: It provides basic description of what is java how it works.. and about the vital use of java in today's world

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


What is Java
Java is a programming language and a platform
...

Platform: Any hardware or software environment in which a program runs, is known as a
platform
...


Java Example
1
...

3
...

5
...
out
...
Compile by: javac Simple
...
Run by: java Simple

Where it is used?
According to Sun, 3 billion devices run java
...
Some of them are as follows:
1
...

3
...

5
...

7
...


Desktop Applications such as acrobat reader, media player, antivirus etc
...
co
...

Enterprise Applications such as banking applications
...


Types of Java Applications
There are mainly 4 type of applications that can be created using java programming:

1) Standalone Application
It is also known as desktop application or window-based application
...
AWT and Swing are
used in java for creating standalone applications
...
Currently, servlet, jsp, struts, jsf etc
...


3) Enterprise Application
An application that is distributed in nature, such as banking applications etc
...
In java, EJB is used for
creating enterprise applications
...
Currently Android and Java ME are used
for creating mobile applications
...
JDK Alpha and Beta (1995)
2
...
0 (23rd Jan, 1996)
3
...
1 (19th Feb, 1997)
4
...
2 (8th Dec, 1998)
5
...
3 (8th May, 2000)
6
...
4 (6th Feb, 2002)
7
...
0 (30th Sep, 2004)
8
...
Java SE 7 (28th July, 2011)
10
...
Features of Java
1
...

3
...


secured
Robust
Architecture Neutral
Portable
High Performance
Distributed
Multi-threaded

5
...

7
...

9
...


There is given many features of java
...
The Java
Features given below are simple and easy to understand
...

removed many confusing and/or rarely-used features e
...
, explicit pointers, operator
overloading etc
...


Object-oriented
Object-oriented

programming

(OOPs)

is

a

methodology

development and maintenance by providing some rules
...

2
...

4
...

6
...
There are
two types of platforms software-based and hardware-based
...
The Java platform differs from most other platforms in the sense that it's
a software-based platform that runs on top of other hardware-based platforms
...
Runtime Environment
2
...
g
...
Java code is
compiled by the compiler and converted into bytecode
...
e
...


Secured
Java is secured because:


No explicit pointer



Programs run inside virtual machine sandbox
...

Bytecode Verifier- checks the code fragments for illegal code that can violate
access right to objects
...





These security are provided by java language
...


Robust
Robust simply means strong
...
There are lack of
pointers that avoids security problem
...

There is exception handling and type checking mechanism in java
...


Architecture-neutral
There is no implementation dependent features e
...
size of primitive types is set
...


High-performance
Java is faster than traditional interpretation since byte code is "close" to native code still
somewhat slower than a compiled language (e
...
, C++)

Distributed
We can create distributed applications in java
...
We may access files by calling the methods from any machine
on the internet
...
We can write Java programs
that deal with many tasks at once by defining multiple threads
...
Threads are important for multi-media,
Web applications etc
...

2
...

4
...


class Simple{
public static void main(String args[]){
System
...
println("Hello Java");
}
}

6
...
java

7
...
java

To execute:

java Simple

8
...
out
...










class keyword is used to declare a class in java
...

static is a keyword, if we declare any method as static, it is known as static method
...
The main method is executed by the JVM, so it doesn't
require to create object to invoke the main method
...

void is the return type of the method, it means it doesn't return any value
...

String[] args is used for command line argument
...

System
...
println() is used print statement
...
out
...


1) By changing sequence of the modifiers, method prototype is not changed
...

Different codes to write the main method
...

2
...


public static void main(String[] args)
public static void main(String []args)
public static void main(String args[])

Valid java main method signature
1
...

3
...

5
...
args)
main(String[] args)

6
...

8
...

2
...

4
...
It is used to provide runtime
environment
...
It physically exists
...

Implementations of JVMs are also actively released by other companies besides Sun
Micro Systems
...
It physically exists
...


JVM (Java Virtual Machine)
JVM (Java Virtual Machine) is an abstract machine
...

JVMs are available for many hardware and software platforms (i
...
JVM is plateform
dependent)
...
A specification where working of Java Virtual Machine is specified
...
Its implementation
has been provided by Sun and other companies
...
An implementation Its implementation is known as JRE (Java Runtime
Environment)
...
Runtime Instance Whenever you write java command on the command prompt to
run the java class, and instance of JVM is created
...


Internal Architecture of JVM
Let's understand the internal architecture of JVM
...


1) Classloader:
Classloader is a subsystem of JVM that is used to load class files
...


3) Heap:
It is the runtime data area in which objects are allocated
...
It holds local variables and partial results, and plays a part in
method invocation and return
...


5) Program Counter Register:
PC (program counter) register
...


6) Native Method Stack:
It contains all the native methods used in the application
...

3) Just-In-Time(JIT) compiler: It is used to improve the performance
...


Variable and Data type in Java
1
...
Types of Variable
3
...


1
...


Instance Variable
A variable that is declared inside the class but outside the method is called instance
variable
...


Static variable
A variable that is declared as static is called static variable
...


Example to understand the types of variables
1
...

3
...

5
...

7
...


Operators

Precedence

Postfix

expr++ expr--

Unary

++expr --expr +expr -expr ~ !

Multiplicative

* / %

Additive

+ -

Shift

<< >> >>>

Relational

< > <= >= instanceof

Equality

== !=

bitwise AND

&

bitwise exclusive OR

^

bitwise inclusive OR

|

logical AND

&&

logical OR

||

Ternary

? :

Assignment

= += -= *= /= %= &= ^= |= <<= >>= >>>=

Fibonacci Series in Java without using recursion
1
...

3
...

5
...

7
...

9
...

11
...

13
...

15
...
out
...
out
...

2
...

4
...

6
...

8
...

10
...

12
...

14
...

16
...


class FibonacciExample2{
static int n1=0,n2=1,n3=0;
static void printFibonacci(int count){
if(count>0){
n3 = n1 + n2;
n1 = n2;
n2 = n3;
System
...
print(" "+n3);
printFibonacci(count-1);
}
}
public static void main(String args[]){
int count=10;
System
...
print(n1+" "+n2);//printing 0 and 1
printFibonacci(count-2);//n-2 because 2 numbers are already printed
}
}
Output:
0 1 1 2 3 5 8 13 21 34

Prime Number Program in Java
1
...

3
...

5
...

7
...

9
...

11
...

13
...

15
...


public static void main(String args[]){
int i,m=0,flag=0;
int n=17;//it is the number to be checked
m=n/2;
for(i=2;i<=m;i++){
if(n%i==0){
System
...
println("Number is not prime");
flag=1;
break;
}
}
if(flag==0)
System
...
println("Number is prime");
}
}
Output:
Number is prime

Palindrome Program
1
...

3
...

5
...

7
...

9
...

11
...

13
...

15
...
out
...
out
...
out
...

2
...

4
...

6
...

8
...

10
...

12
...

14
...
out
...

2
...

4
...

6
...


153 = (1*1*1)+(5*5*5)+(3*3*3)
where:
(1*1*1)=1
(5*5*5)=125
(3*3*3)=27
So:
1+125+27=153
why 371 is an Armstrong number
...

2
...

4
...


371 = (3*3*3)+(7*7*7)+(1*1*1)
where:
(3*3*3)=27
(7*7*7)=343
(1*1*1)=1

6
...


So:
27+343+1=371
class ArmstrongExample{
public static void main(String[] args) {
int c=0,a,temp;
int n=153;//It is the number to check armstrong
temp=n;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a);
}
if(temp==c)
System
...
println("armstrong number");
else
System
...
println("Not armstrong number");
}
}
Output:

1
...

3
...

5
...

7
...

9
...

11
...

13
...

15
...

17
...

19
...

21
...


armstrong number
class Student6{
int id;
String name;
Student6(int i,String n){
id = i;
name = n;
}
Student6(Student6 s){
id = s
...
name;
}
void display(){System
...
println(id+" "+name);}
public static void main(String args[]){
Student6 s1 = new Student6(111,"Karan");
Student6 s2 = new Student6(s1);
s1
...
display();
}

}
Output:
111 Karan
111 Karan


Title: Basics of java
Description: It provides basic description of what is java how it works.. and about the vital use of java in today's world