Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
depending on their data type or class. More specifically, it is
the ability to redefine methods for derived classes.
Department of Computer Science and Engineering
Sub. Code: CS6501
Date: 06.08.2015
Sub. Name: Internet Programming
Duration: 3 Hours
3. What is mean by Multithreading? [ Dec’11, May’12]
Multithreading in java is a process of executing multiple
threads simultaneously.
Thread is basically a lightweight sub-process, a smallest unit
Internal Test – I
Answer Key
PART – A (10 × 2 = 20)
1. Briefly discuss the JVM.
[May’13 and Dec’13]
The Java Compiler is converting from Source code
into the Byte code. But java compiler is not executable code.
Rather, it is byte code. Bytecode is highly optimized set of
instructions designed to be executed by the Java run – time
system, which is called the Java Virtual Machine (JVM).
That is, in its standard form, the JVM is an interpreter for
used to achieve multitasking.
But we use multithreading than multiprocessing because
threads share a common memory area. They don't allocate
separate memory area so saves memory, and contextswitching between the threads takes less time than process.
Java Multithreading is mostly used in games, animation etc.
4. Compare between the Multitasking and Multithreading
[Dec’10,11 and May’12,13]
multitasking:heavyweight process and runs in a different
address space so context switch or intercommunication
bytecode.
2. Define Polymorphism.
of processing. Multiprocessing and multithreading, both are
[Dec’10 and Nov’11]
In object-oriented programming, polymorphism refers to a
programming language's ability to process objects differently
between
processes
is
much
expensive.
Where as multithreading: light weight process and can run
in
a
same
address
space
so
context
switch
intercommunication between processes is less expensive.
5. What is an Exception? Give an example. [May’12]
or
An Exception is condition that is caused by a run – time
<td align="right">IN001</td>
error in the program.
<td>Dr.
Ex:
A
P
J
Abdul
Kalam</td>
ArithmeticException
</tr>
OverflowExcetion
<tr>
<td align="right">IN002</td>
6. Write HTML code to create the following Table.
[May’13]
<td>Atal
COUNTRY ID
BHARATH RATHANA LEGEND
Bihari
Vajpayee</td>
</tr>
IN001 Dr. A P J Abdul Kalam
</center>
IN002 Atal Bihari Vajpayee
</body>
<html>
</html>
<head>
7. How does differs XHTML from HTML? [May’13]
<title>Creating a Table</title>
</head>
1. All tags must be in lower case
<body>
2. All documents must have a doctype
3. All documents must be properly
<center>
formed
<tr>
<th>COUNTRY ID</th>
4. All tags must be closed
<th>BHARATH
5. All attributes must be added properly
RATHNA
6. The name attribute has changed
LEGEND</th>
</tr>
7. Attributes cannot be shortened
<tr>
8. All tags must be properly nested
<h2 style=font-family:times new roman;font8. Write Core Syntax for the CSS. [May’11, 12]
style:italic;fontweight:
500;font-size:x-small>Department of Computer Science and
Engineering</h2>
</body>
</html>
10. List the ways of positioning an element within a browser
window. [Dec’12]
a. Static Positioning
b. Fixed Positioning
c. Relative Positioning
9. Give Example for inline style sheet. [May’13]
d. Absolute Positioning
<html>
<head>
PART – B
<title>Inline Style Sheets</title>
(Answer all the Questions)
</head>
<body>
<h1 style=font-family:arial black;font-style:normal;fontweight:
900;font-size:xx-large>Welcome to Chettinad College of
Engineering
and Technology</h1>
11. (a) Explain the different types of inheritance with
suitable example. [Dec’11, 12, May’12 and May’11] (16)
Single Inhertiance (One Super class Only on Sub class)
Multilevel Inheritance (Derived from the Derived class)
Hierarchical Inheritance (Only one Super class and
number of Sub class)
(or)
3. We cannot declare abstract constructors or abstract
(b) Explain the following concept with suitable example.
(i) abstract keyword
static methods.
You can require that certain methods be overridden by
(ii) super Keyword
subclasses by specifying the abstract type modifier. These
The purpose of the ‘super’ keyword:
methods
are
sometimes
responsibility because
referred
to
they have
no
as
subclasser
1. Using super to call Superclass Constructors
implementation
specified in the super class . Thus, a subclass must override
2. Using super to call Superclass Methods
Using super to Call Superclass Constructor
them – it cannot simply use the version defined in the
A Subclass can call a constructor method
superclass. To declare an abstract method, use this general
defined by its superclass by use of the following form of
form:
super:
abstract type name (parameter – list)
super (parameter – list)
Any class that contains one or more abstract methods must
Here, parameter – list specifies any parameter
also be declared abstract. To declare a class abstract, you
needed by the constructor in the superclass, super() must
simply use the abstract keyword in from of the class
always be the first statement executed inside a subclass
keyword at the beginning of the class declaration.
constructor.
Conditions for the Abstract Class
Restriction of the Subclass constructor
1. We cannot use abstract classes to instantiate
objects directly. For
example. Shape s = new Shape(); is illegal because
shape is an abstract class.
2. The abstract methods of an abstract class must be
defined in its subclass.
1. super may only be used within a subclass
constructor method.
2. The call to superclass constructor must
appear as the first statement within the subclass constructor
3. The parameters in the super call must match
12. (a) Explain the Exception Handling mechanism with
the order and type of the instance variable declared in the
suitable example. [AU’ Question]
superclass.
The purpose of the exception handling mechanism is to
(iii) Method overriding
provide means to detect and report an “exceptional
1. Method overriding in java means a subclass
circumstance”, so that appropriate action can be taken.
method overriding a super class method.
The Error Handling code that performs the following
2. Superclass method should be non-static.
tasks:
3. Subclass uses extends keyword to extend the super
1. Find the problem (Hit the Exception)
class.
(16)
2. Inform that an error has occurred (Throw the exception)
4. In the example class B is the sub class and class A
is the super class.
3. Receive the error information (Catch the exception)
4. Take corrective actions (Handle the exception)
5. In overriding methods of both subclass and
superclass possess same
signatures.
6. Overriding is used in modifying the methods of the
super class.
7. In overriding return types and constructor
parameters of methods should match.
(iv) sealed keyword
1. Can’t initialize to variable again and again (Equivalent to
Constant)
2. Can’t Method Overriding
3. Can’t Inherited
(or)
(b) Explain the Multithreading concept using java with
This can be achieved by creating the thread and initiating it
suitable example. [AU’ Question]
with the help of
(16)
CREATING THREADS
1. Creating threads in Java is simple.
another thread method called start().
A new thread can be created in two ways.
2. Threads are implemented in the form of objects
a. By creating a thread class:
that contain a method
called run().
Define a class that extends Thread class and
override its run()
3. The run() method is the heart and soul of any
thread. It makes up the
entire body of a thread and is the only method in
method with the code required by the
thread.
b. By converting a class to a thread:
which the thread’s
behaviour can be implemented.
Define a class that implements Runnable
interface. The Runnable
4. A typical run() would appear as follows:
interface has only one method, run(), that
is to be defined in the
method with the code to be executed by
the thread.
EXTENDING THE THREAD CLASS
We can make our class runnable as a thread by extending
the class java.lang.Thread. This gives us access to all the
The run() method should be invoked by an object for the
concerned thread.
thread methods directly.
It includes the following steps:
System.out.println("\tFrom Thread A :
1. Declare the class as extending the Thread
i = " + i);
class
}
System.out.println("Exit from A ");
2. Implement the run() method that is
responsible for executing the sequence of code that the
thread will execute.
3. Create a thread object and call the start()
method to initiate the thread execution.
13. (a) Explain the following multithreading function in java
with suitable example.
(i)
sleep()
(ii)
start()
(iii)
isAlive()
(iv)
yield()
(v)
setPriority()
import java.lang.Thread;
class A extends Thread
{
public void run()
{
for(int i = 1;i <= 5;i++)
{
if(i == 1) yield();
(16)
}
}
class B extends Thread
{
public void run()
{
for(int j = 1;j <= 5;j++)
{
System.out.println("\tFrom Thread B :
j = " + j);
if(j==3) stop();
}
System.out.println("Exit from B ");
}
}
class C extends Thread
{
public void run()
{
for(int k = 1;k <= 5;k++)
{
System.out.println("\tFrom Thread C :
k = " + k);
if(k==1)
try
{
sleep(1000);
}
catch(Exception e)
{
}
}
System.out.println("Exit from C ");
for(int i = 1;i <= 5;i++)
{
System.out.println("\tFrom Thread A :
i = " + i);
}
System.out.println("Exit from A ");
}
}
class ThreadTest_1
{
public static void main(String args[])
{
A a = new A();
B b = new B();
C c = new C();
System.out.println("Start Thread A");
a.start();
System.out.println("Start Thread B");
b.start();
System.out.println("Start Thread C");
c.start();
System.out.println("End of main Thread");
}
}
class A extends Thread
{
public void run()
{
}
}
class B extends Thread
{
public void run()
{
for(int j = 1;j <= 5;j++)
{
System.out.println("\tFrom Thread B :
j = " + j);
}
System.out.println("Exit from B ");
}
}
class C extends Thread
{
public void run()
{
for(int k = 1;k <= 5;k++)
{
System.out.println("\tFrom Thread C :
k = " + k);
}
System.out.println("Exit from C ");
}
}
System.out.println("Main
Thread
Interrupted");
class ThreadTest
{
public static void main(String args[])
{
A a = new A();
B b = new B();
C c = new C();
System.out.println("Start Thread A");
a.start();
System.out.println("Start Thread B");
b.start();
System.out.println("Start Thread C");
c.start();
System.out.println("End of main Thread");
}
System.out.println("Thread One is Alive: " +
a.isAlive());
System.out.println("Thread two is Alive: " +
b.isAlive());
System.out.println("Thread three is Alive: " +
c.isAlive());
}
}
import java.lang.Thread;
class A extends Thread
{
public void run()
{
for(int i = 1;i <= 5;i++)
{
System.out.println("Thread One is Alive: " +
a.isAlive());
System.out.println("Thread two is Alive: " +
b.isAlive());
System.out.println("Thread three is Alive: " +
c.isAlive());
try
{
a.join();
b.join(); c.join();
}
catch(InterruptedException e)
{
System.out.println("\tFrom
Thread A : i = " + i);
}
System.out.println("Exit from A ");
}
}
class B extends Thread
{
public void run()
{
for(int j = 1;j <= 5;j++)
{
System.out.println("\tFrom Thread B :
b.setPriority(10);
//b.setPriority(MAX_PRIORITY);
a.setPriority(1);
//a.setPriority(MIN_PRIORITY);
j = " + j);
}
System.out.println("Exit from B ");
}
a.start();
}
class C extends Thread
{
public void run()
{
for(int k = 1;k <= 5;k++)
{
System.out.println("\tFrom Thread C :
k = " + k);
b.start();
c.start();
}
}
(or)
(b) Explain the any 16 XHTML tags with suitable
example. [AU Question]
}
System.out.println("Exit from C ");
}
}
class ThreadPriority
{
public static void main(String args[])
{
A a = new A();
B b = new B();
C c = new C();
c.setPriority(5);
//c.setPriority(NORM_PRIORITY);
(16)
<h1>
<a>
<table>
<form>
<img>
<b>
<i>
<u>
<ul>
<ol>
<li>
<hr>
<p>
<pre>
<br>
<input>
14. (a) Design a user registration form using XHTML.
(16) [AU Question]
<html xmlns = "http://www.w3.org/1999/xhtml">
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<head>
<title>Creating Registration Form using XHTML
Forms</title>
</head>
<body>
<center><font face="arial black" size="30">Registration
Form</font></center>
<pre>
<form
name="f1"
action="http://localhost:8080/servlets/Example_Servlet"
method="get">
if, any other Details
<textarea
name="ta1">
</textarea>
<input type="submit" name="s22" value="Submit"> <input
type="reset" name="r22" value="Reset">
</body>
</html>
(or)
(b) Explain the following cascading style sheet with
example. [AU Question]
Enter the First Name
name="t1" value="">
Enter the Last Name
name="t2" value="">
Select the Desgination
<input
type="text"
<input
type="text"
<select name="s1">
<option>Lecture</option>
<option>Senior Lecturer</option>
<option>Assitant Professor</option>
<option>Associate Professor</option>
<option>Professor</option>
</select>
Gender
<input
type="radio"
name="r1"
value="">Male
<input
type="radio" name="r1" value="">Female
Address
<textarea name="ta"> </textarea>
Hoppies
<input type="checkbox" name="c1"
value="">Cricket
<input
type="checkbox" name="c2" value="">Football
<input type="checkbox" name="c3" value="">Hockey <input
type="checkbox" name="c4' value="">Volleyball
(16)
(i) Internal style sheet
(ii) Inline style sheet
(iii) External style sheet
15. (a) (i) Explain the different type of selectors in CSS with
example. [AU Question]
(8)
a. Tag or Element selector
b. Id selector
c. Class selector
d. Group selector
(ii) Explain the font attribute in CSS with example.
(8)
(ii) Text attributes
(or)
(b) Explain the following attributes in CSS with example.
(16)
(i) Background attributes [AU Question]
Subject In – Charge / CSE
HOD / CSE