You are on page 1of 6

Register No.

SNS COLLEGE OF ENGINEERING


Kurumbapalayam(Po), Coimbatore 641 107
Accredited by NAAC-UGC with A Grade
Approved by AICTE & Affiliated to Anna University, Chennai

INTERNAL ASSESSMENT EXAMINATIONS - I


COURSE: B.E CSE
CS6501 INTERNET PROGRAMMING-ANSWER KEY
Class: V Sem CSE A & B
Date: 01 August 2015
Duration: 2 Hours
Maximum: 50 Marks
Answer ALL questions
PART A - (7 X 2 = 14 marks)

1.

2.

3.

4.

5.

A Java virtual machine (JVM) is an abstract computing machine. There are three notions of
the JVM: specification, implementation, and instance.
The specification is a book that formally describes what is required of a JVM
implementation.
A JVM implementation is a computer program that meets the requirements of the
JVM specification in a compliant and preferably performant manner.
An instance of the JVM is a process that executes a computer program compiled
into Java bytecode.
In object-oriented programming (OOP), inheritance is when an object or class is based on
another object (prototypal inheritance) or class (class-based inheritance), using the same
implementation (inheriting from an object or class) specifying implementation to maintain
the same behavior (realizing an interface; inheriting behavior).
It is a mechanism for code reuse and to allow independent extensions of the original
software via public classes and interfaces. The relationships of objects or classes through
inheritance give rise to a hierarchy.
The default constructor can refer to a constructor that is automatically generated by the
compiler in the absence of any programmer-defined constructors (e.g. in Java), and is
usually a nullary constructor.
In other languages (e.g. in C++) it is a constructor that can be called without having
to provide any arguments, irrespective of whether the constructor is auto-generated
or user-defined.
A constructor with formal parameters can still be called without arguments if default
arguments were provided in the constructor's definition.
Abstract class
Interface
Abstract class can have abstract and non- Interface can have only abstract methods.
abstract methods.
Abstract class can have final, non-final, Interface has only static and final variables.
static and non-static variables.
Abstract
class can
provide
the Interface can't provide the implementation
implementation of interface.
of abstract class.
Does not support multiple inheritance
Supports multiple inheritance
When we extend Thread class, we cant extend any other class which you require. (Java
does not allow inheriting more than one class). When we implement Runnable, we can save
1

a space for your class to extend any other class in future or now.
However, the significant difference is. when we extends Thread class, each of your thread
creates unique object and associate with it. When we implements Runnable, it shares the
same object to multiple threads.

6.

Embedded style sheet


Embedded styles are placed within a style
element within the head section of an
HTML document.

External style sheet


The preferred way of using styles is
typically to use external styles. An external
stylesheet is basically a css file containing a
set of style rules
The primary benefit of an external
stylesheet is that it can be referenced by
multiple HTML documents.

Embedded styles can help abstract style


information into a common location in a
document.
Byte stream classes
BufferedInputStream
BufferedOutputStream
DataInputStream
DataOutputStream.
7.
Character stream classes
BufferedReader
BufferedWriter
FileReader
FileWriter

PART B - (3 X 12 = 36 marks)
8.

(a)

(i)

(ii)

Java control statements


Java Control statements in a programming language are very useful as they allow
a programmer to change the flow of program execution i.e. altering the normal
program flow to jump directly on some statement(s) or to skip a statement(s). In
Java control statements are divided into following 3 categories:
Selection/Decision making Statements
If
if-else
switch
Loop/ Iteration Statements
While
do-while
for
Branching/ Transfer statements
Break
Continue
Syntax and Example program for each.

Parameterized Consructor
class Rectangle {
int length;
int breadth;
Rectangle(int len,int bre)
{
2

length = len;
breadth = bre;
}
}
class RectangleDemo {
public static void main(String args[]) {
Rectangle r1 = new Rectangle(20,10);
System.out.println("Length of Rectangle : " + r1.length);
System.out.println("Breadth of Rectangle : " + r1.breadth);
}
}
OR
(b)

(i)

12
Java Package
Package are used in Java, in-order to avoid name conflicts and to control access of
class, interface and enumeration etc. A package can be defined as a group of
similar types of classes, interface, enumeration and sub-package. Using package it
becomes easier to locate the related classes.
Packages are categorized into two forms:
Built-in Package:-Existing Java package for

example java.lang, java.util etc.


User-defined-package:- Java package created by user to categorized

classes and interface


Example:
package mypack
class Book
{
String bookname;
String author;
Book(String b, String c)
{
this.bookname = b;
this.author = c;
}
3

public void show()


{
System.out.println(bookname+" "+ author);
}
}

class test
{
public static void main(String[] args)
{
Book bk = new Book("java","Herbert");
bk.show();
}
}

9.

(a)

(i)

Exception handling
Exception handling is done by transferring the execution of a program to an
appropriate exception handler when exception occurs.
Try is used to guard a block of code in which exception may occur. This block of
code is called guarded region.
A catch statement involves declaring the type of exception you are trying to catch.
If an exception occurs in guarded code, the catch block that follows the try is
checked, if the type of exception that occured is listed in the catch block then the
exception is handed over to the catch block which then handles it.
class Division {
public static void main(String[] args) {
int a, b, result;
Scanner input = new Scanner(System.in);
System.out.println("Input two integers");
a = input.nextInt();
b = input.nextInt();
// try block
try {
result = a / b;
System.out.println("Result = " + result);
}
// catch block
catch (ArithmeticException e) {
System.out.println("Exception caught: Division by zero.");
4

12

}
}
}
.
OR
(b)

(i)

Abstract class

Abstract class is a class which cant be instantiated and should be


inherited to access the members.

It forces the subclass to follow certain standards and rules as in base class
[to follow the filed set and methods as defined in Abstract Class].

An abstract class can contain either abstract methods or non-abstract


methods.

12

Interface

Interface is not a class; it is an entity that gives basic signature of the


method but not the definition.

As same as abstract class It forces the subclass to follow certain


standards and rules in derived class

Example program-Student Mark Evaluation system


(a)

10.

(i)

(ii)

img
<img src="smiley.gif" alt="Smiley face" height="42" width="42">
map
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planet
map">
p
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
<area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
<area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>
<p>This is some text in a paragraph.</p>
a href
<a href="http://www.w3schools.com">Visit W3Schools</a>
HTML
<h1>My h1 heading </h1>
<h2> My h2 heading </h2>

CSS
h1 {
font-weight: bold;
color: #fff;
font-size: 32px;
}
5

h2 {
font-weight: bold;
color: #fff;
font-size: 24px;
}
OR
(b)

(i)

External,embedded,inline CSS
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
h1 {color:blue;}
h2 {color:red;}
p {color:green;}
</style>
<title>Hello World</title>
<link rel=stylesheet type="text/css" href="css/Helloworld.css">
</head>
<body>
<h1>Hello World, this is my first HTML</h1>
<p style="color:red;font-size:18px">This is a paragraph!</p>
</body>
</html>
*****

12

You might also like