Saturday, 28 October 2017

Computer network introduction

What is a Network?

A network is simply defined as something that connects things together for

a specific purpose. The term network is used in a variety of contexts,

Including telephone, television, computer, or even people networks.

A computer network connects two or more devices/computers together to share a nearly limitless range of information and services, including:

·        Documents

·        Email and messaging

·        Websites

·        Databases

·        Music

In below diagram Ok and An connected through a network.

Now come to the Point Protocol:--

Protocols are rules that govern how devices communicate and share

information across a network. Examples of protocols include:

1. IP – Internet Protocol

2. HTTP - Hyper Text Transfer Protocol

Multiple protocols often work together to facilitate end-to-end network

Communication. Protocols are covered in great detail later .

Basic Types of Network:--

Network types are often defined by function or size or no of connected workstations. The two most common categories of networks are:

·        LANs (Local Area Networks)

·        WANs (Wide Area Networks)

A LAN is generally a high-speed network that covers a small geographic

area, usually contained within a single building or campus. A LAN is

usually under the administrative control of a single organization. Ethernet is the most common LAN technology.

A WAN can be defined one of two ways. The book definition of a WAN is a

network that spans large geographical locations, usually to connect multiple


A MAN (Metropolitan Area Network) is another category of network,

though the term is not prevalently used. A MAN is defined as a network that

connects LAN’s across a city-wide geographic area.

An internetwork is a general term describing multiple networks connected

together. The Internet is the largest and most well-known internetwork.

Network Architectures

A host refers to any workstation that is connected to a network. A host can also

 defined as any device assigned an IP address.

A host can use following functions:

• A host which request data, called as a client.

• A which provide data, called as a server.

• A host can both request and provide data, called as a peer.

Because of these functions, multiple network architectures have

been developed, including:

1.     Peer-to-Peer

2.     Client/Server

3.     Mainframe/Terminal

In a basic peer-to-peer architecture, all hosts on the network can both

request and provide data and services. For example, two Windows 10

workstations configured to share files would be considered a peer-to-peer


Peer-to-peer networks are very simple to configure like static routes, yet this architecture presents several challenges. Data is difficult to manage and back-up, as it is spread across multiple workstation. Security is equally problematic, as user

accounts and permissions much be configured individually on each host.

Explanations No 1:--

In a client/server architecture, systems are assigned specific roles. Clients

request data and services stored on servers. An example of a client/server

network would be Windows 10 workstations accessing files off of a

Windows 2007 server.

Advantage of the client/server:--

There are several advantages to the client/server architecture. Data and

services are now centrally located on one or more servers, consolidating the

security and management of that data. As a result, client/server networks can

scale far larger than peer-to-peer networks.

disadvantage of the client/server:--

One key disadvantage of the client/server architecture is that  server can

present a single point of failure. This can be mitigated by adding redundancy at the server layer.

interface in Java

interface keyword

An interface is a keyword in java, it is used to declare interface in java. Like a class, interface can have methods and variables, but the methods declared in interface must be abstract. It is used to achieve abstraction and multiple inheritance in java. Methods in an interface are implicitly public.

Writing interface similar to writing a class. But class describes the attributes and behaviours of an object. And an interface contains behaviours that a class implements.  

Syntax to declare interface:

interface <interface-name>{

//abstract methods



interface Add{

public int add( );


How to implement interface

A class uses implement keyword to implement an interface. If class does not define all the methods of interface then the class must be declared as abstract.

Now we will explain how to implement an interface via this following example.



interface Add{

public int add( int a, int b);


class Complete implements Add{

public int add(int a, int b){

return a+b;



public class Sum{

public static void main(String [ ]q){

Complete obj=new Complete();

int c=obj.add(5,12);

System.out.println("Sum of  two numbers is "+c);




Sum of two numbers is 17

Code explanation:

In this program First we created one interface named as Add and then after we implement this interface by Complete class and this Complete class define the method that is declared inside interface. Now we create third class named as Sum and this class contains main method. Inside this main method we create object of Complete class and via this object we access the method and get the value of addition of two numbers. After getting the addition of two numbers we print that value using System.out.println( ).


Since java 8, interface can have default and static methods.

Friday, 27 October 2017

abstract keyword in java

What is abstract keyword

abstract keyword is used to implement the abstraction in java. A method which does not have method definition must be declared as abstract. You can't instantiate abstract classes. Abstract methods must be implemented in the sub classes. We can't use abstract keyword with variables and constructors.

What is abstract class

An abstract class is a class that is declared as abstract. It may or may not be include abstract method. If a class has at least one abstract method, then the class must be declared as abstract class. abstract classes cannot be instantiated , but they can be extended. If we extended an abstract class, we have to provide implementation to all the abstract methods in it.

What is abstract method

An abstract method is a method that is declared without an implementation.

Example 1:

public abstract int add(int a, int b);

An abstract method must always be declared in an abstract class or in other word we can say that if a class has an abstract method, it should be declared as abstract.

Now we will take one example to explain abstract class and abstract method

Example 2:


abstract class Add{

abstract public int add(int a, int b);


class Complete extends Add{

public int add(int a, int b){

return a+b;



public class Sum{

public static void main(String [ ]p){

Complete obj=new Complete( );

int c=obj.add(5,12);

System.out.println("addtion of two numbers is"+c);



Output of the program:

addition of two numbers is 17

Code Explanation:

In above program first we created an abstract class named as Add and it contains one abstract method add and then we created a class named as Complete that inherits the Add class. Complete class provide implementation to the abstract method of Add class. Now we create third class named as Sum. Inside this main class we create object of Complete class and by using the object we call the add method and it returns sum of the given values and we print the value.

Thursday, 26 October 2017

Keywords in Java

The java programming language has total of 50 reserved keywords which have special meaning for the compiler and can not be used for used as identifiers. 

Here list of keywords in the Java programming language

1. abstract           2.assert                           3.boolean          4.break                5.byte                 7.catch                            8.char                9.class                 10.const 

11.continue       12.default                               14.double            15.else 

16.enum            17.extends                           19.finally            20.float   

21.for                22.goto                            23.if                   24.implements    25.import    

26.instanceof                               28.interface       29.long                30.native              32.package                      33.private          34.protected        35.public

36.return           37.short                           38.static             39.strictfp           40.super   

41.switch          42.synchronized             43.this                44.throw             45.throws

46.transient       47.try                             48.void               49.volatile           50.while

The keywords const and goto are reserved, even though they are not currently used.

true, false and null might seem like keywords, but they are actually literals, you can not use them as identifiers in programs.

Note: All the keywords should be used in lower case.