This thesis considers several instances of abstraction that arose in the design and implementation of the web programming language Links. The first concerns user interfaces, specified
using HTML forms. We wish to construct forms from existing form fragments without introducing dependencies on the ...
CS6501 - Internet programming
Unit- I
Part - A
1 Define Java.
Java is a programming language expressly designed for use in the distributed environment of the Internet. It was
designed to have the "look and feel" of the C++ language, but it is simpler to use than C++ and enforces an object-
oriented programming model.
2. What is a Class?
Class is a template for a set of objects that share a common structure and a common behaviour.
3. What is an Object?
n
Object is an instance of a class. It has state,behaviour and identity. It is also called as an instance of a class.
4. What is an Instance?
g.i
An instance has state, behaviour and identity. The structure and behaviour of similar classes are defined in their
common class. An instance is also called as an object.
5. What are different types of access modifiers (Access specifiers)?
n
Access specifiers are keywords that determine the type of access to the member of a class. These keywords are for
allowing privilegesto parts of a program such as functions and variables. These are: public: Anything declared as
eri
public can be accessed from anywhere.
private: Anything declared as private can’t be seen outside of its class.
protected: Anything declared as protected can be accessed by classes in the same package and subclasses in the
there packages.
e
default modifier : Can be accessed only to classes in the same package.
gin
6. What is method overloading and method overriding?
Method overloading: When a method in a class having the same method name with different arguments is said to
be method overloading.
Method overriding: When a method in a class having the same method name with same arguments is said to be
en
method overriding.
7. List the access specifier used in JAVA?
Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors.
arn
The four access levels are:
• Visible to the package. the default. No modifiers are needed.
• Visible to the class only (private).
• Visible to the world (public).
Le
• Visible to the package and all subclasses (protected).
8. What is the difference between Array and vector?
Array is a set of related data type and static whereas vector is a growable array of objects and dynamic
9. What is a package?
w.
A package is a collection of classes and interfaces that provides a high-level layer of access protection and name
space management.
10. What is meant by Inheritance?
ww
Inheritance is a relationship among classes, wherein one class shares the structure or behaviour defined in another
class. This is called Single Inheritance. If a class shares the structure or behaviour from multiple classes, then it is
called Multiple Inheritance. Inheritance defines “is-a” hierarchy among classes in which one subclass inherits from
one or more generalised superclasses.
11. What is an Abstract Class?
Abstract class is a class that has no instances. An abstract class is written with the expectation that its concrete
subclasses will add to its structure and behaviour, typically by implementing its abstract operations.
12. What are inner class and anonymous class?
Inner class: classes defined in other classes, including those defined in methods are called inner classes. An inner
class can have any accessibility including private.
For More Visit : www.Learnengineering.in
, For More Visit : www.Learnengineering.in
Anonymous class: Anonymous class is a class defined inside a method without a name and is instantiated and
declared in the same place and cannot have explicit constructors.
13. Define interface and write the syntax of the Interface.
Interface is an outside view of a class or object which emphaizes its abstraction while hiding its structure and
secrets of its behaviour.
Syntax:
[visibility] interface InterfaceName [extends other interfaces] {
constant declarations
abstract method declarations
}
n
14. What is the difference between abstract class and interface?
a) All the methods declared inside an interface are abstract whereas abstract class must have at least one abstract
g.i
method and others may be concrete or abstract.
b) In abstract class, key word abstract must be used for the methods whereas interface we need not use that
keyword for the methods.
n
c) Abstract class must have subclasses whereas interface can’t have subclasses.
15. What is an exception?
eri
An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the
program's instructions.
16. What is meant by JAVA package?(Nov/Dec 2014)
e
Package represents a collection of classes, methods and interface. The name of the package must be written as the
gin
first statement in the java source program.The syntax of specifying the package in the java program is:package
name_of_package
17. What are the types of Exceptions in Java?
There are two types of exceptions in Java, unchecked exceptions and checked exceptions.
en
Checked exceptions: A checked exception is some subclass of Exception (or Exception itself), excluding class
RuntimeException and its subclasses. Each method must either handle all checked exceptions by supplying a catch
clause or list each unhandled checked exception as a thrown exception.
arn
Unchecked exceptions:All Exceptions that extend the RuntimeException class are unchecked exceptions. Class
Error and its subclasses also are unchecked.
18. What are the different ways to handle exceptions?
There are two ways to handle exceptions:
• Wrapping the desired code in a try block followed by a catch block to catch the exceptions.
Le
• List the desired exceptions in the throws clause of the method and let the caller of the method handle those
exceptions.
19. How to create custom exceptions? By Extending
w.
the Exception class or one of its subclasses.
class MyException extends Exception {
ww
public MyException() { super(); }
public MyException(String s) { super(s);
} }
20. Write the properties of Threads.(Nov/Dec 2014).
• Thread Priority
• Deamon Thread
• Thread group
21. What is multi-threaded programming?(Nov/Dec 2014)
Multithreading is the ability of a program or an operating system process to manage its use by more than one user
at a time and to even manage multiple requests by the same user without having to have multiple copies of the
For More Visit : www.Learnengineering.in
, For More Visit : www.Learnengineering.in
programming running in the computer.
22. Write the life cycle of thread.
A thread goes through various stages in its life cycle. For example, a thread is born, started, runs, and then dies.
Following diagram shows complete life cycle of a
n
n g.i
thread.
e eri
gin
23. What is daemon thread and which method is used to create the daemon thread?
A daemon thread is a thread, that does not prevent the JVM from exiting when the program finishes but the thread
is still running. An example for a daemon thread is the garbage collection. You can use the setDaemon() method to
change the Thread daemon properties
en
24. What is the purpose of toString() method in java ?
The toString() method returns the string representation of any object. If you print any object, java compiler
internally invokes the toString() method on the object. So overriding the toString() method, returns the desired
output, it can be the state of an object etc. depends on your implementation.
arn
25. What is immutable string in java?
In java, string objects are immutable. Immutable simply means unmodifiable or unchangeable.Once string object
is created its data or state can't be changed but a new string object is created.
Eg:
Le
class Testimmutablestring{
public static void main(String args[]){
String s="Sachin";
w.
s.concat(" Tendulkar");//concat() method appends the string at the end
System.out.println(s);//will print Sachin because strings are immutable objects
}
ww
26. Define assert .
Java assertion feature allows developer to put "assert" statements in Java source code to help unit testing and
debugging.
An "assert" statement has the following format:
assert boolean_expression : string_expression;
When this statement is executed:
If boolean_expression evaluates to true, the statement will pass normally.
If boolean_expression evaluates to false, the statement will fail with an "AssertionError" exception.
27. Define Applet.
An applet is a small Internet-based program written in Java, a programming language for the Web, which can be
downloaded by any computer. The applet is also able to run in HTML. The applet is usually embedded in an
For More Visit : www.Learnengineering.in
, For More Visit : www.Learnengineering.in
HTML page on a Web site and can be executed from within a browser.
28. Define transient and volatile Modifiers.
Java defines two interesting type modifiers: transient and volatile. These modifiers are usedto handle somewhat
specialized situations. When an instance variable is declared as transient, then its value need not persist when an
object is stored. For example:
class T {
transient int a; // will not persist
int b; // will persist
}
Here, if an object of type T is written to a persistent storage area, the contents of a would not be saved, but the
n
contents of b would.
29. What is use of the run-time operator instanceof.
g.i
The instanceof operator has this general form:
objref instanceof type
Here, objref is a reference to an instance of a class, and type is a class type. If objref is of the specified type or can
n
be cast into the specified type, then the instanceof operator evaluates to true. Otherwise, its result is false. Thus,
instanceof is the means by which your program canobtain run-time type information about an object
eri
30. How to Enabling and Disabling Assertion Options?
When executing code, you can disable assertions by using the -da option. You can enable or disable a
specific package by specifying its name after the -ea or -da option. For example, to enable assertions in a package
called MyPack, use
-ea:MyPack e
gin
To disable assertions in MyPack, use
-da:MyPack
31. Define String Constructors.
The String class supports several constructors. To create an empty String, you call the default
en
constructor. For example,
String s = new String();
will create an instance of String with no characters in it. Frequently, you will want to create strings that have initial
arn
values. The String class provides a variety of constructors to handle this. To create a String initialized by an array
of characters, use the constructor shown here:
String(char chars[ ])
Here is an example:
Le
char chars[] = { 'a', 'b', 'c' };
String s = new String(chars);
This constructor initializes s with the string “abc”.
32. What are the String Comparison?
w.
The String class includes several methods that compare strings or substrings within strings.
equals( ) and equalsIgnoreCase( To compare two strings for equality, use equals( ). To perform a
) comparison that ignores case differences, call equalsIgnoreCase( ).
ww
regionMatches( ) The regionMatches( ) method compares a specific region inside a string
with another specificregion in another string.
startsWith( ) and endsWith( ) The startsWith( ) method determines whether a given String begins with a
specified string.
Conversely, endsWith( ) determines whether the String in question ends
with a specifiedstring.
equals( ) Versus == The equals( ) method compares the characters insidea String object. The
== operator compares two object references to see whether they referto the
same instance.
compareTo( ) to simply know whether two strings are identical
For More Visit : www.Learnengineering.in
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller ramkumarramadoss. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $7.99. You're not tied to anything after your purchase.