Btechadda.com

Java

OOPS/JAVA downloads

by Shivu on May.08, 2010, under Java

JAVA Downloads

Unit 1

http://www.ziddu.com/download/9164946/OOPS-UNIT-2-byHkesavaraju4btechadda.pdf.html

Unit-2

http://www.ziddu.com/download/9164946/OOPS-UNIT-2-byHkesavaraju4btechadda.pdf.html

Unit 3

http://www.ziddu.com/download/9258306/OOPS-UNIT-3-byHkesavaraju4btechadda.com.pdf.html

Unit-5

http://www.ziddu.com/download/9258397/OOPS-UNIT-5-byHkesavaraju4btechadda.com.pdf.html

Unit 8

http://www.ziddu.com/download/9772855/javaunit8byhkesavarajuforbtechadda.pdf.html

Leave a Comment more...

OOPS/JAVA:Basics of Networking Programming

by hkesavaraju on May.07, 2010, under Java

Basics of Network Programming: The basics of networking fall into the following categories.

a) Overview of Socket: A network Socket is almost like an electrical socket. The various plugs around the network have a standard way of delivering their payloads. Anything which understands the standard protocol can plug in to the socket and communicate. There are many protocols used. They are:

(i) IP is a low level protocol which breaks data into small packets and forwards them to an address across the network but it doesn’t guarantee safe transmission.

(ii) TCP is a high level protocol which strings together all these packets and provides reliable transmitting of data.

(iii) UDP is next to TCP but it provides fast, unreliable connectionless packet transmission.

b) Proxy Servers: There are situations where a client has certain restrictions to communicate directly with the server. In such cases, the client would contact a proxy server which doesn’t have such restrictions and is easy to communicate with the client. A proxy server has ability to filter some requests or cache the results of those requests for the future use.

A cache proxy HTTP server is used to reduce the bandwidth demands on a local network’s connections to the internet. A proxy server is used in situations where a popular web site is being hit by several users, proxy server gets those pages and providing faster accessing them to the clients by saving expensive transfers each time it is hit by each user.

c) Internet Addressing: Internet address is the number that uniquely identifies each computer on the net. Each and every computer in internet has an address. This address can be represented either by IPV4 OR IPV6. IPV4 represents address in 32 bit format and is widely used scheme where as IPV6 represents address in 128 bit format..

d) Domain Name Service: I every one referred the addresses as numbers, then it won’t easy to navigate over the internet. Hence, a parallel hierarchy of names exists for the all these numbers which known as DNS. The name of the internet address known as domain name describes machine’s location in a name space from right to left.

e) client servers: A server is one which has some resource that can be shared. There are computer servers that provide computing power, print servers that manage a collection of printers, disk servers that provide networked disk space and web servers which store web pages.

A client is one which wants to access a particular server. The interaction between a client and server is just like an interaction between a lamp and an electrical socket. A server should be capable of accepting multiple clients connected to the same port number, although each session is unique.

f) Reserved Sockets: The high level protocol when connected ensures the port on which it is dependent. The TCP/IP reserves 1,024 ports for specific protocols. The protocol finds how a client should interact with the port. An example is HTTP is the protocol which is used for transferring pages and images.

g) Currency: It is included in java version 1.4 and is defined in java.util package. The structure of Currency is as follows:

public final class Currency extends Object implements Serializable

The Currency class represents a currency of a country. Currencies are identified by their ISO 4217 currency codes. Currency don’t have constructors and its instance is obtained by using getInstance().

Note: It is used to represent currencies of US dollars or Japanese Yen.

The Objects of currency class doesn’t represent a particular amount of currency but the currency unit itself.

The following program illustrates the Currency class:

public class currencydemo

{

public staticvoid main(String args[])

{

Currency c1=Currency.getInstance(Locale.US); // obtains instance for US dollar

System.out.println(“US dollar symbol is”+c1.getSymbol());

System.out.println(“US dollar in Canada is”+c1.getSymbol(Locale.CANADA);

Currency c2=Currency.getInstance(Locale.JAPAN); // obtains japan currency based on Locale

System.out.println(“the currency code for japan is”+c2.getCurrencyCode());

Currency c3=Currency.getInstance(“JPY”); // obtains japan currency based on code

if(c2!=c3) // compare currency objects

System.out.println(“objects are unequal”);

}

}

Output:

US dollar symbol is : $

US dollar in Canada is -

the currency code for japan is -

Leave a Comment more...

OOPS/JAVA UNIT 3 Uses of super keyword

by hkesavaraju on Apr.02, 2010, under Java

3.7 Uses of super keyword:

 (i) To avoid sub class constructor to explicitly initialize the super class instance variables and also to avoid duplicate code in its super class.

(ii) There will be times to create super class that keeps the details of its implementation to itself. In that case, the sub class is not allowed to access super class variables directly or super class initialize those variables on its own.

(iii) Java provides a solution in which a sub class refers to its immediate super class using super keyword.

Super has two general forms.

3.7.1 First form:  The first form is used to call a constructor method defined in its super class. It’s form is super(parameter-list);

where parameter-list specifies the parameters of the constructor in the super class. It should be always first statement executed inside the subclass constructor.

See how super() is used in the following example:

class Box
{
double w,h,d;
Box(Box ob)     // object is passed to constructor
{
w=ob.w;
h=ob.h;
d=ob.d;
}
Box( double w1,double h1,double d1)
{
w=w1;
h=h1;
d=d1;
}
Box()
{
w=-1;
h=-1;
d=-1;
}
Box(Double len)
{
w=h=d=len;
}
double volume()
{
return w*h*d;
}
}
class BoxWeight extends Box
{
double m;
BoxWeight(double w1,double h1,double d1,double wg)
{
super(w1,h1,d1);
m=wg;
}
BoxWeight(BoxWeight ob)
{
super(ob);
m=ob.m;
}
BoxWeight(double len,double w1)
{
super(len);
m=w1;
}
BoxWeight()
{
super();
m=-1;
}
}
class demo
{
public static void main(String args[])
{
BoxWeight m1=new BoxWeight(2,3,4,6.0);
BoxWeight m2=new BoxWeight(10,20,30,8.0);
BoxWeight m3=new BoxWeight();
BoxWeight m4=new BoxWeight(3,2);
BoxWeight m5=new BoxWeight(m1);
double vol;
vol=m1.volume();
System.out.println(“volume of object m1 is”+vol);
System.out.println(“weight of object m1 is”+m1.m);
vol=m2.volume();
System.out.println(“volume of object m2 is”+vol);
System.out.println(“weight of object m2 is”+m2.m);
vol=m3.volume();
System.out.println(“volume of object m3 is”+vol);
System.out.println(“weight of object m3 is”+m3.m);
vol=m4.volume();
System.out.println(“volume of object m4 is”+vol);
System.out.println(“weight of object m4 is”+m4.m);
vol=m5.volume();
System.out.println(“volume of object m5 is”+vol);
System.out.println(“weight of object m5 is”+m5.m);
}
}

Output:

volume of object m1 is 24.0
weight of object m1 is 6.0
volume of object m2 is 48000.0
weight of object m2 is 8.0
volume of object m3 is -1.0
weight of object m3 is 1.0
volume of object m4 is 27.0
weight of object m1 is 2.0
volume of object m1 is 24.0
weight of object m1 is 6.0

In this, The class demo which has main() creates m1 object for sub class BoxWeight , the first statement super(w1,h1,d1) calls Box() constructor that takes three arguments such as w1,h1,d1 and are initialized to w, h & d respectively.

The second statement creates m2 for BoxWeight class, in which the first statement super(w1,h1,d1) calls Box() constructor that takes three double arguments.

The third statement creates object m3 for BoxWeight , in Which BoxWeight constructor has first statement  super() which calls Box() constructor that takes no arguments.

The fouth statement crates object m4 for BoxWeight, in which BoxWeight constructor has

super(len) that calls Box() constructor that takes one double argument.

The fifth statement creates object m5 for BoxWeight, in which BoxWeight constructor has first statement super(ob) calls Box constructor that takes Box reference as an argument.

Second form: 

This second form acts some what like this, except it always refer to the super class of the sub class in which it is used. It’s general form is

super.member where member can be either a method or an instance variable.

This second form can be used in most situations in which member names of a sub class hides same name in the super class.

The following program illustrates this second form:

class A
{
int i;
}
class B extends A
{
int i;
B(int a, int b)
{
super.i=a;
i=b;
}
void show()
{
System.out.println(“i in super class is”+super.i);
System.out.println(“i in sub class is”+i);
}
}
class superdemo
{
public static void main(String args[])
{
B ob=new B(1,2);
ob.show();
}
Output:

i in super class is 1

i in sub class is 2

Note: This second form of super is used to avoid the hiding of super class variables.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...