New Microsoft Word Document

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1.

An Applet is a small Internet-based Program that has the Graphical User Interface (GUI),written in the Java Programming
Language .

2.Applets are designed to run inside a Web Browser or in applet viewer to facilitate the user to animate the graphics ,play
sound and design the GUI components such as Text Box,button …etc

Applets can load data from File that is specified with a relative Uniform Locator(URL)Applets display documents in Web
Browser using show Document() method to display. When an applet is executed ,it goes through the four stages of its life
cycle. init(): Initialization of an Applet that loads the applet first time into memory start():The applet starts running
stop():The applet stops runningdestroy(): The applet is unloaded or destroyed from the memory paint():method belongs
to the Graphics class in Java. It is used to draw shapes in the applet.

All Applets are subclass of the Applet class, which is available in java.applet package. We must import java.applet package
and extend our class from Applet class .In addition we have to import java.awt package as it is required to provide a user
interface to an applet Class hierarchy given as follows :

java.lang.Object

java.awt.Component

java.awt.Container

java.awt.Panel

java.awt.Applet

The class java.awt.Graphics defines the methods for drawing lines and other shapes such as Rectangle,arcs,images and text.

Java provides Abstract window Toolkit(AWT) it is an api to create A GUI –based window application is an application in
which a user interacts through various components,such as Text fields and buttons. java.awt ,components

Swing is part of Java Foundation Classes. It is used to create window-based applications which makes it suitable for
developing lightweight desktop applications. Java Swing is built on top of an abstract windowing toolkit API purely written in
Java programming language.javax.swing and the components are jbutton,jtexfield,jtextbox.

Class: A class is a group of objects which have common properties. It is a template or blueprint from which objects are
created. It is a logical entity. It can't be physical. A class in Java can contain: Fields, Methods, Constructors, Blocks, Nested
class and interface

Object: An object is an instance of a class. It is a real-world entity which has state and behavior. It can be physical or logical.
Characteristics of object are: State: represents the data (value) of an object. Behavior: represents the behavior
(functionality) of an object such as deposit, withdraw, etc. Identity: An object identity is typically implemented via a unique
ID. The value of the ID is not visible to the external user. However, it is used internally by the JVM to identify each object
uniquely.
Method Overloading is an object Oriented technique that lets you define several different versions of a method ,all
with a same name, but each with a different parameter list.
When you use overloaded methods, the java compiler decides which method is to be invoked by the number
and/or types of the parameter you can pass to the method.
Methods are overloaded on the basis of the following facts: Number of Parameter, Type of Parameter , Order of
Parameter

Method Overriding is also a object oriented technique that lets you define methods with the same name in the super-class
and sub-class when you implement inheritance. When you use Method overriding the compiler decides which method is to
be invoked by the object ,which is used to invoke that method.

Constructors are special type of methods having the same name as the class name. For example, if the class name has
demo then the constructor will also have the name Demo. A constructor initializes the objects as soon as the object is
created A constructor does not have any return-type and not even void because implicitly the return type of the
constructor is class itself

Static Member that is common to all objects and accessed without using a particular object .The member belongs to the
class as a whole rather than the objects created from class

Constructor overloading: Constructor overloading in Java is a technique of having more than one constructor with different
parameter lists. They are arranged in a way that each constructor performs a different task. They are differentiated by the
compiler by the number of parameters in the list and their types.

Constructor overriding: Constructor Overriding is never possible in Java because, Constructor looks like a method but name
should be as class name and no return value. Overriding means what we have declared in Super class, that exactly we have
to declare in Sub class it is called Overriding. Super class name and Sub class names are different. If you trying to write Super
class Constructor in Sub class, then Sub class will treat that as a method not constructor because name should not match
with Sub class name. And it will give an compilation error that methods does not have return value. So we should declare as
void, then only it will compile.

Jdk: The Java Development Kit (JDK) is a software development environment that offers a collection of tools and libraries
necessary for developing Java applications. You need the JDK to convert your source code into a format that the Java
Runtime Environment (JRE) can execute.

Jvm: Java Virtual Machine (JVM) is a engine that provides runtime environment to drive the Java Code or applications. It
converts Java bytecode into machines language. JVM is a part of Java Runtime Environment (JRE).

Priciples of java

1. Inheritance: It is a concept that is used for code re-usability. A class that inherits the features of another class is called
the Sub class.(parent-child relationship)
2. Encapsulation: It is a concept that acts like a binding force. It prevents unauthorized access of a class from outside
users. Encapsulation means 'in capsule' that means that everything is secured so that security of the class is maintained.
It is implemented by the use of access specifiers for example public, private, protected.
3. Polymorphism: Polymorphism means many forms. It is a concept that allows one interface to be used for a general
class of actions. It is also called 'one interface many methods '. Method overriding is a part of polymorphism.
Polymorphism is a concept that is implemented at run-time.

The Exception Handling in Java is one of the powerful mechanism to handle the runtime errors so that normal flow of the

application can be maintained. Exceptions are events that occur during program execution and interrupt the flow of the
program. All possible exceptions supported by Java are organised as subclass in a hierarchy under the Throwable class and
under java.lang package

Using the try-catch block-The try block in a Java program is used to enclose a statement that may lead to an exception .A try
block must be followed by a catch block.The catch block acts as an execption handler and contains the object of specified
exception class ,which handles the raised exception

Using Nested try-catch Block-We can also nest multiple try-catch blocks inside one try block in a program

the finally Clause-The finally block is used to display information or to execute statements ,which need to be executed
irrespective of the catch block.This Means that a finally block must be executed in spite of the fact that catch block is
executed or not. A finally block must be declared at the end of the last catch block .If finally block is declared before catch

block the program will not execute.Multiple finally block cannot be used without a try block. System.exit() method is called
before executing the finally block.

Using the throws Clause-The throws clause is used when you know that a method may cause exceptions,but the method is
incapable of handling exceptions. In such case user has to throw those exceptions to the caller of the method by using
throws clause

Using throw clause -To throw exception explicitly ,an object of that exception type need to be created .To create an object of
any exception type,the throw clause is used .

Builtin Exceptions- ArithmeticException, ArrayIndexOutOfBoundsException, ClassNotFoundException,


FileNotFoundException, IOException

User-defined Exceptions-We can also create our own exception type to describe the exception related to your applications in
your own way

Thread is the smallest unit of an execution code in a program .It helps you divide a process in multiple parts to speed up the
process.A process is a program that executes as a single thread. Programs that run as single thread can cause problems

when you perform two or more task simultaneously. To overcome such problem ,Java provides built-in support for
multithreading programming, which enables a single program to perform multiple task simultaneously.creation of thread is
done by By extending the Thread class By implementing the Runnable interface Implementing the java.lang.Runnable
Interface or java.lang.Thread class
Objectives of multithreading are To use the idle time of a CPU.For creating faster and interactive applications.For designing
a Network For creating animations .

Types of inheritance: single level, multilevel, hierarchical, hybrid,multiple

Super keyword: The super keyword in java is a reference variable that is used to refer parent class objects and can also be
used to access the specific variable of a superclass.

Abstract keyword : The abstract keyword is used to achieve abstraction in Java. It is a non-access modifier which is used to
create abstract class and method. The role of an abstract class is to contain abstract methods.

Abstract method:An abstract method is a method that is declared without an implementation (without braces, and followed
by a semicolon),

Vectors: Vector is like the dynamic array which can grow or shrink its size. Unlike array, we can store n-number of elements
in it as there is no size limit. It is a part of Java Collection framework. Each class has its own features and the class used to
store a type of data determines how it can be accessed and manipulated

ToArray(): Converts a vector to an array

Set(): Changes an element in a vector

Iterator(): Iterates through a vector

ToString(): Converts a vector to a string

The final keyword is used for more than one purpose in Java programming .It can be used with classes and members .When
the final keyword is used with a variable ,the final variable is treated as constant and you cannot modify its value.

Abstraction: it is a process of hiding the implementation details and showing only functionality to the user.

You might also like