Files 1 2021 February NotesHubDocument 1613556627
Files 1 2021 February NotesHubDocument 1613556627
Files 1 2021 February NotesHubDocument 1613556627
1. Question No. 1 should be compulsory and cover the entire syllabus. This question should have objective or short answer type
questions. It should be of 25 marks.
2. Apart from Question No. 1, rest of the paper shall consist of four units as per the syllabus. Every unit should have two questions.
However, student may be asked to attempt only 1 question from each unit. Each question should be of 12.5 marks
UNIT I
Overview and characteristics of Java, Java program Compilation and Execution Process Organization of the Java Virtual Machine,
JVM as an interpreter and emulator, Instruction Set, class File Format, Verification, Class Area, Java Stack, Heap, Garbage Collection.
Security Promises of the JVM, Security Architecture and Security Policy. Class loaders and security aspects, sandbox model
[T1,R2][No. of Hrs.: 11]
UNIT II
Java Fundamentals, Data Types & Literals Variables, Wrapper Classes, Arrays, Arithmetic Operators, Logical Operators, Control of
Flow, Classes and Instances, Class Member Modifiers Anonymous Inner Class Interfaces and Abstract Classes, inheritance, throw and
throws clauses, user defined Exceptions, The String Buffer Class, tokenizer, applets, Life cycle of applet and Security concerns.
[T1,T2][No. of Hrs.: 12]
UNIT III
Threads: Creating Threads, Thread Priority, Blocked States, Extending Thread Class, Runnable Interface, Starting Threads, Thread
Synchronization, Synchronize Threads, Sync Code Block, Overriding Synced Methods, Thread Communication, wait, notify and notify
all.AWT Components, Component Class, Container Class, Layout Manager Interface Default Layouts, Insets and Dimensions, Border
Layout, Flow Layout, Grid Layout, Card Layout Grid Bag Layout AWT Events, Event Models, Listeners, Class Listener, Adapters,
Action Event Methods Focus Event Key Event, Mouse Events, Window Event
[T2][No. of Hrs.: 11]
UNIT IV
Input/Output Stream, Stream Filters, Buffered Streams, Data input and Output Stream, Print Stream Random Access File, JDBC
(Database connectivity with MS-Access, Oracle, MS-SQL Server), Object serialization, Sockets, development of client Server
applications, design of multithreaded server. Remote Method invocation, Java Native interfaces, Development of a JNI based
application. Collection API Interfaces, Vector, stack, Hashtable classes, enumerations, set, List, Map, Iterators. [T1][R1][No. of Hrs.:
10]
Text Books:
[T1] Patrick Naughton and Herbertz Schidt, “Java-2 the complete Reference”,TMH
Reference Books:
Java is everywhere:
1. Java resides in mobile phones, client machines, server machines, embedded services,
smart phones, cloud etc
2. It shares the same basic language features and libraries.
3. Principle of JAVA: Write Once, Run Anywhere (WORA)
Library?
It is a collection of pre defined classes. You can use these library either by inheriting them or
instantiating them.
Java Editions
Features
● Simple
● Object Oriented
● Distributed
● Interpreted
● Robust
● Secure
● Portable
● Multi threaded
● Garbage Collector
1. Jdk download
https://www.oracle.com/in/java/technologies/javase-downloads.html
2 https://www.oracle.com/java/technologies/javase-jdk14-downloads.html
Setting a path:
1. C:\Program Files\Java\jdk-14.0.2\bin
2. Go to System settings of environment variable
3. In the Path, add: C:\Program Files\Java\jdk-14.0.2\bin
4. Add New:
5. Variable name: JAVA_HOME
6. Variable value : C:\Program Files\Java\jdk-14.0.2
How to Compile and Run?
The language a computer can understand is called machine language or machine code.
When you run a program written in high-language, which is human-readable source code like
mycode.java, you first need to compile it before you can run it. The compiler translates codes
written in high-language into byte code (mycode.class)
There's a special interpreter that translates your byte code into machine language, this
interpreter is called Java Virtual Machine a.k.a JVM. It is the JVM that runs your java
code.
How to Run?
Difference between C and java?
C JAVA
Java is Object-Oriented
C is a Procedural Programming Language.
language.
the code into machine language so that it transformed into bytecode and
Machine).
real world.
anywhere.
free is used for freeing the memory in C. memory internally by calling the
garbage collector.
management. memory.
run time.
program.
language. statements.
Platform independent,
Platform dependent,
Java bytecode works
Platform Dependency should be compiled for
on any operating
different platform.
System.
C++ is platform
It can run in any OS
Portability dependent hence it is
hence it is portable.
not portable.
interfaces.
It supports only
It supports both
method overloading
Overloading methods and operators
and doesn’t allow
overloading.
operator overloading.
services
Architecture
1. Class Loader : It is a sub system used for loading class files, it performs 3 main functions:
Loading, linking and initialization
actually calls the main method present in a java code. JVM is a part of JRE(Java Runtime
Environment).
Java applications are called WORA (Write Once Run Anywhere). This means a programmer can
develop Java code on one system and can expect it to run on any other Java enabled system without
When we compile a . java file, .class files(contains byte-code) with the same class names present in
.java file are generated by the Java compiler. This . class file goes into various steps when we run it.
Class Loader Subsystem
● Loading
● Linking
● Initialization
Loading : The Class loader reads the .class file, generate the corresponding binary data and save it in
method area. For each . class file, JVM stores following information in method area.
● Fully qualified name of the loaded class and its immediate parent class.
● Whether . class file is related to Class or Interface or Enum
● Modifier, Variables and Method information etc.
After loading .class file, JVM creates an object of type Class to represent this file in the heap memory.
Please note that this object is of type Class predefined in j ava.lang package. This Class object can be
used by the programmer for getting class level information like name of class, parent name, methods
and variable information etc. To get this object reference we can use g
etClass() method of Object
class.
Initialization : In this phase, all static variables are assigned with their values defined in the code and
static block(if any). This is executed from top to bottom in a class and from parent to child in class
hierarchy.
● Bootstrap class loader : Every JVM implementation must have a bootstrap class loader,
capable of loading trusted classes. It loads core java API classes present in
JAVA_HOME/jre/lib directory. This path is popularly known as bootstrap path. It is
implemented in native languages like C, C++.
● Extension class loader : It is child of bootstrap class loader. It loads the classes present in
the extensions directories J
AVA_HOME/jre/lib/ext(Extension path) or any other directory
specified by the java.ext.dirs system property. It is implemented in java by the
sun.misc.Launcher$ExtClassLoader class.
● System/Application class loader : It is child of extension class loader. It is responsible to
load classes from application class path. It internally uses Environment Variable which
mapped to java.class.path. It is also implemented in Java by the
sun.misc.Launcher$AppClassLoader class.
Note : JVM follow Delegation-Hierarchy principle to load classes. System class loader delegate load
request to extension class loader and extension class loader delegate request to boot-strap class
loader. If class found in boot-strap path, class is loaded otherwise request again transfers to extension
class loader and then to system class loader. At last if system class loader fails to load class, then we
JVM Memory
Method area :In method area, all class level information like class name, immediate parent class
name, methods and variables information etc. are stored, including static variables. There is only one
Heap area :Information of all objects is stored in heap area. There is also one Heap Area per JVM. It is
Stack area :For every thread, JVM create one run-time stack which is stored here. Every block of this
stack is called activation record/stack frame which store methods calls. All local variables of that
method are stored in their corresponding frame. After a thread terminate, it’s run-time stack will be
PC Registers :Store address of current execution instruction of a thread. Obviously each thread has
separate PC Registers.
Native method stacks :For every thread, separate native stack is created. It stores native method
information.
Execution Engine
Execution engine execute the .class (bytecode). It reads the byte-code line by line, use data and
information present in various memory area and execute instructions. It can be classified in three
parts :-
● Interpreter : It interprets the bytecode line by line and then executes. The disadvantage
here is that when one method is called multiple times, every time interpretation is required.
● Just-In-Time Compiler(JIT) : It is used to increase efficiency of interpreter.It compiles the
entire bytecode and changes it to native code so whenever interpreter see repeated
method calls,JIT provide direct native code for that part so re-interpretation is not
required,thus efficiency is improved.
● Garbage Collector : It destroy un-referenced objects.For more on Garbage Collector,refer
Garbage Collector.
It is an interface which interacts with the Native Method Libraries and provides the native libraries(C,
C++) required for the execution. It enables JVM to call C/C++ libraries and to be called by C/C++
It is a collection of the Native Libraries(C, C++) which are required by the Execution Engine.