0% found this document useful (0 votes)
13 views72 pages

Java Slides TSR

The document outlines the Wipro Talent Next exam dates and provides an extensive overview of Java technology, including its programming language features, application types, and platforms. It covers the Java Virtual Machine architecture, variable types, data types, and how to write and run Java programs. Additionally, it explains the differences between JDK, JRE, and JVM, as well as how to set the Java path in various operating systems.

Uploaded by

nagarohini2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views72 pages

Java Slides TSR

The document outlines the Wipro Talent Next exam dates and provides an extensive overview of Java technology, including its programming language features, application types, and platforms. It covers the Java Virtual Machine architecture, variable types, data types, and how to write and run Java programs. Additionally, it explains the differences between JDK, JRE, and JVM, as well as how to set the Java path in various operating systems.

Uploaded by

nagarohini2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 72

WIPRO TALENT NEXT EXAM DATES

• MileStone-1 : 01-June-2022

• MileStone-2 : 13-June-2022

• MileStone-3 : 24-June-2022

• MileStone-4 : 01-August-2022
About the Java Technology
Java technology is both a programming language and a platform.
The Java Programming Language
The Java programming language is a high-level language that can be characterized by all of the
following buzzwords:

•Simple
•Object oriented
•Distributed
•Multithreaded
•Dynamic
•Architecture neutral
•Portable
•High performance
•Robust
•Secure
What Can Java Technology Do?
Every full implementation of the Java platform gives you the following features:
Development Tools: The development tools provide everything you'll need for compiling,
running, monitoring, debugging, and documenting your applications. As a new developer,
the main tools you'll be using are the javac compiler, the java launcher, and
the javadoc documentation tool.

Application Programming Interface (API): The API provides the core functionality of the
Java programming language. It offers a wide array of useful classes ready for use in your
own applications. It spans everything from basic objects, to networking and security, to
XML generation and database access, and more. The core API is very large; to get an
overview of what it contains, consult the Java Platform Standard Edition 8 Documentation.

Deployment Technologies: The JDK software provides standard mechanisms such as the
Java Web Start software and Java Plug-In software for deploying your applications to end
users.
What Can Java Technology Do?

User Interface Toolkits: The JavaFX ( Special effects ), Swing, and Java 2D toolkits make it
possible to create sophisticated Graphical User Interfaces (GUIs).

Integration Libraries: Integration libraries such as the Java IDL API (Interface Definition
Language ), JDBC API, Java Naming and Directory Interface (JNDI) API, Java RMI, and Java
Remote Method Invocation over Internet Inter-ORB Protocol Technology (Java RMI-IIOP
Technology) enable database access and manipulation of remote objects.

How Will Java Technology Change My Life?

Get started quickly:


Write less code:
Write better code:
Develop programs more quickly:
Avoid platform dependencies
Write once, run anywhere:
Distribute software more easily:
Application

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


•Web Applications such as irctc.co.in, javatpoint.com, etc.
•Enterprise Applications such as banking applications.
•Mobile
•Embedded System
•Smart Card
•Robotics
•Games, etc.

•Types of Java Applications

•Standalone Application
•Web Application
•Enterprise Application
•Mobile Application
Java Platforms / Editions

Java SE (Java Standard Edition)


It is a Java programming platform. It includes Java programming APIs such as java.lang,
java.io, java.net, java.util, java.sql, java.math etc. It includes core topics like OOPs,
String, Regex, Exception, Inner classes, Multithreading, I/O Stream, Networking, AWT,
Swing, Reflection, Collection, etc.

Java EE (Java Enterprise Edition)


It is an enterprise platform that is mainly used to develop web and enterprise
applications. It is built on top of the Java SE platform. It includes topics like Servlet, JSP,
Web Services, EJB, JPA, etc.

Java ME (Java Micro Edition)


It is a micro platform that is dedicated to mobile applications.

JavaFX
It is used to develop rich internet applications. It uses a lightweight user interface API.
The Java Platform
A platform is the hardware or software environment in which a program runs.

The Java platform has two components:


The Java Virtual Machine
The Java Application Programming Interface (API)
First Java Program | Hello World Example

The requirement for Java Hello World Example


For executing any Java program, the following software or application must be properly
installed.
•Install the JDK if you don't have installed it, download the JDK and install it.
•Set path of the jdk/bin directory. http://www.javatpoint.com/how-to-set-path-in-java
•Create the Java program
•Compile and run the Java program
An overview of the software development process.
Creating Hello World Example

class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
To write the simple program, you need to open notepad by start menu -> All Programs ->
Accessories -> Notepad and write a simple program as we have shown below:
In order to compile and run the above program, you need to open the command prompt
by start menu -> All Programs -> Accessories -> command prompt. When we have done
with all the steps properly, it shows the following output:
In how many ways we can write a Java program?

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


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

2) The subscript notation in the Java array can be used after type, before the variable
or after the variable.
public static void main(String[] args)
public static void main(String []args)
public static void main(String args[])

3) You can provide var-args support to the main() method by passing 3 ellipses (dots)
public static void main(String... args)

4) Having a semicolon at the end of class is optional in Java.


class A{
static public void main(String... args){
System.out.println("hello java4");
}

;
}
Valid Java main() method signature
public static void main(String[] args)
public static void main(String []args)
public static void main(String args[])
public static void main(String... args)
static public void main(String[] args)
public static final void main(String[] args)
final public static void main(String[] args)
final strictfp public static void main(String[] args)

Invalid Java main() method signature

public void main(String[] args)


static void main(String[] args)
public void static main(String[] args)
abstract public static void main(String[] args)
Resolving an error "javac is not recognized as an internal or external command"?

Solution is set the java class path


What happens at compile time?

Classloader: It is the subsystem of JVM that is used to load


class files.

Bytecode Verifier: Checks the code fragments for illegal code


that can violate access rights to objects.

Interpreter: Read bytecode stream then execute the


instructions.
Can you save a Java source file by another name than the class name?
Yes, if the class is not public. It is explained in the figure given below:

To compile: javac Hard.java


To execute: java Simple

Observe that, we have compiled the code with file name but running the program
with class name. Therefore, we can save a Java program other than class name.
Can you have multiple classes in a java source file?
Yes, like the figure given below illustrates:
How to set path in Java

If you are saving the Java source file inside the JDK/bin directory, the path is not required
to be set because all the tools will be available in the current directory.

There are two ways to set the path in Java:


1. Temporary
2. Permanent

1) How to set the Temporary Path of JDK in Windows


To set the temporary path of JDK, you need to follow the following steps:
•Open the command prompt
•Copy the path of the JDK/bin directory
•Write in command prompt: set path=copied_path
For Example:
set path=C:\Program Files\Java\jdk1.6.0_23\bin
2) How to set Permanent Path of JDK in Windows
For setting the permanent path of JDK, you need to follow these steps:
•Go to MyComputer properties -> advanced tab -> environment variables -> new tab of
system variable -> write path in variable name -> write path of bin folder in variable value ->
ok -> ok -> ok
For Example:

1) Go to MyComputer properties 2) Click on the advanced tab


3) Click on environment variables
4) Click on the new tab of System variables
Setting Java Path in Linux OS
export PATH=$PATH:/home/jdk1.6.01/bin/

Difference between JDK, JRE, and JVM


JVM (Java Virtual Machine) Architecture

JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides


runtime environment in which java bytecode can be executed.

JVMs are available for many hardware and software platforms (i.e. JVM is platform
dependent).
What is JVM
It is:
A specification where working of Java Virtual Machine is specified. But implementation
provider is independent to choose the algorithm. Its implementation has been provided
by Oracle 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, an instance of JVM is created.
JVM Architecture
1) Classloader
Classloader is a subsystem of JVM which is used to load class files. Whenever we run the
java program, it is loaded first by the classloader. There are three built-in classloaders in
Java.

Bootstrap ClassLoader: This is the first classloader which is the super class of Extension
classloader. It loads the rt.jar file which contains all class files of Java Standard Edition like
java.lang package classes, java.net package classes, java.util package classes, java.io
package classes, java.sql package classes etc.

Extension ClassLoader: This is the child classloader of Bootstrap and parent classloader of
System classloader. It loades the jar files located inside $JAVA_HOME/jre/lib/ext directory.

System/Application ClassLoader: This is the child classloader of Extension classloader. It


loads the classfiles from classpath. By default, classpath is set to current directory. You
can change the classpath using "-cp" or "-classpath" switch. It is also known as
Application classloader.
2) Class(Method) Area
Class(Method) Area stores per-class structures such as the runtime constant pool, field
and method data, the code for methods.
3) Heap
It is the runtime data area in which objects are allocated.
4) Stack
Java Stack stores frames. It holds local variables and partial results, and plays a part in
method invocation and return.
Each thread has a private JVM stack, created at the same time as thread.
A new frame is created each time a method is invoked. A frame is destroyed when its
method invocation completes.
5) Program Counter Register
PC (program counter) register contains the address of the Java virtual machine instruction
currently being executed.
6) Native Method Stack
It contains all the native methods used in the application.
7) Execution Engine
1. A virtual processor
2. Interpreter: Read bytecode stream then execute the instructions.
3. Just-In-Time(JIT) compiler: It is used to improve the performance. JIT compiles parts
of the byte code that have similar functionality at the same time, and hence reduces
the amount of time needed for compilation. Here, the term "compiler" refers to a
translator from the instruction set of a Java virtual machine (JVM) to the instruction
8) Java Native Interface
Java Native Interface (JNI) is a framework which provides an interface to communicate
with another application written in another language like C, C++, Assembly etc. Java uses
JNI framework to send output to the Console or interact with OS libraries.

Java Variables
Variable is a name of memory location.
There are three types of variables in java: local, instance and static.
There are two types of data types in Java : primitive and non-primitive.

int data=50;//Here data is variable


Variable Declaration:
To declare a variable, you must specify the data type & give the variable a unique name.

Examples of other Valid Declarations are


int a,b,c;
float pi;
double d;
char a;

Variable Initialization:
To initialize a variable, you must assign it a valid value.

Example of other Valid Initializations


are
pi =3.14f;
d0 =20.22d;
a=’v’;
Variable Declaration and Initialization:

Example :
int a=2,b=4,c=6; float pi=3.14f; double do=20.22d; char a=’v’;

Types of variables
In Java, there are three types of variables:
Local Variables
Instance Variables
Static Variables
1) Local Variables
Local Variables are a variable that are declared inside the body of a method.
2) Instance Variables
Instance variables are defined without the STATIC keyword .They are defined Outside a
method declaration. They are Object specific and are known as instance variables.
3) Static Variables
Static variables are initialized only once, at the start of the program execution. These
variables should be initialized first, before the initialization of any instance variables.
Example: Types of Variables in Java
class aits {
static int a = 1; //static variable
int data = 99; //instance variable
void method() {
int b = 90; //local variable
}
}

What is Data Types in Java?


Data Types in Java are defined as specifiers that allocate different sizes and types of
values that can be stored in the variable or an identifier. Java has a rich set of data types.
Data types in Java can be divided into two parts :
Primitive Data Types :- which include integer, character, boolean, and float
Non-primitive Data Types :- which include classes, arrays and interfaces.
Data Type Default Value Default size
boolean false 1 bit
char '\u0000' 2 byte
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte
float 0.0f 4 byte
double 0.0d 8 byte
Points to Remember:
•All numeric data types are signed(+/-).
•The size of data types remain the same on all platforms (standardized)
•char data type in Java is 2 bytes because it uses UNICODE character set. By virtue of it,
Java supports internationalization. UNICODE is a character set which covers all known
scripts and language in the world
class Demo {
public static void main(String args[]) {
byte x; int a = 270; double b = 128.128;
System.out.println("int converted to byte");
x = (byte) a;
System.out.println("a and x " + a + " " + x);
System.out.println("double converted to int");
a = (int) b;
System.out.println("b and a " + b + " " + a); System.out.println("\
ndouble converted to byte");
x = (byte)b;
System.out.println("b and x " + b + " " + x);
}
}

Output:
int converted to byte
a and x 270 14
double converted to int
b and a 128.128 128
double converted to byte
b and x 128.128 -128

You might also like