Facebook And The Java Programming Language Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Face book is social network. In Face book user can add Friends, Delete Friends, Add Groups or Communities and Views Friend of Friends etc. In UEL Book any student studying in UEL can register and login using user ID and password. User can Add Friends, View Friends, View Friends of Friends, Get Friends Profile (like Surname and First Name), Add Group ,List of Groups, List of People in Group, Person With Largest Number of Friends, Person With Largest Friends of Friends ,Largest Group ,Person in Largest Number of Groups and etc .

This is project is a J2SE Project. In this project we use basic concepts like ArrayList, Iteration and Swing Package.


Java is Object Oriented Programming Language.

A Java program is a collection of objects talking to other objects by invoking each other's method. Every object in Java is of certain type, and that type is defined by 'class' or 'interface'. Most Java programs use a collection of objects of many difference types.


A Class that describes the kind of state and behaviour that objects of its type supports

Object: At runtime when JVM encounters the 'new' keyword, it will use the appropriate class to make an object which is an instance of that class. This Object will have its own state, and access to all of the behaviours defined by its class.

State: Each Object instance of class will have its own unique set of instance variable as defined in the class.


When a programmer creates a class, he creates method for that class. Methods are where class's logic is stored. Method is where the real work get done .They are algorithms get executed, and data gets manipulated.


Inheritance allows code defined in one class to be reused in other classes. In java, we can define a general (more abstract) superclass, and then it extends with more specific super class. The super class knows nothing of the class that inherit from it, but all the subclass that inherit from the superclass must explicitly declare the inheritance relationship. Any subclass that inherits from a superclass must explicitly declare the inheritance relationship. A subclass that inherit from a superclass is automatically given accessible instance variable and method define by its super class, but also free to override superclass to define more specific behaviour.

For example, a Car super class could define method common to all automobiles, but BMW subclass could override the accelerate() method. Here are two most common reasons to use inheritance are

1) To promote code reuse.

2) Polymorphism (IS-A and HAS-A Relationship)

In object oriented programming language, the concept of IS-A is based on class inheritance or interface. For example, "a Mustang is a type of horse", so in object oriented terms we can say, "Like Mustang IS-A Horse" "BMW IS-A Car". We can express the IS-A relationship in java through the keyword "extends" for class inheritance and "implements" for interface implementation.

Inheritance tree for vehicle car

Has-A relation:

Has-A relation is based on relation, rather that inheritance. In other words class A HAS-A B if code as has a reference to an instance of class B. For example I can say the following

"A Horse IS-A Animal" . "A Horse HAS-A Halter".


Any object in Java that can pass more than one IS-A test can be considered polymorphic. All java objects are polymorphic in that they pass the IS-A test for their own type and for class object except the objects of type object. Only way to access object is through a reference variable

A reference variable can be of only one data type, and once declared, that type can never be changed.

A reference can be reassigned to another object unless the reference is declared final.

A reference variable's type determines the method that can be invoked on the object the variable is referencing.

A class cannot have more than one parent class. That means it cannot extend more the on class. A class can have multiple ancestors for example class B could extends class A, and class C could extend class B , and so on. Therefore any give class can have multiple classes up its inheritance tree.


The ArrayList is commonly used class in Collection framework. Most important advantage of ArrayList is

It can grow dynamically

It provide more powerful insertion and search mechanism than array

In order to instantiate an ArrayList polymorphically like this

List myList = new arrayList();

As of Java 5

List<String> myList = new arrayList<String> ();

In Java 5, <String> syntax is the way we declare a collection type. In many ways, ArrayList is similar to String () in that it declares a container that holds only Strings, but it's more powerful than a String ().

Wrapper Class:

A Collection can hold only Objects but not primitives. Wrapper Class is used to get primitive data types in to collection. Prior to Java 5, primitive must be wrapped before we put into the collection. With Java 5, Primitive still have to wrapped, but auto boxing takes care of it.

List myList = new arrayList ();

myList.Add (new Integer (33));

As of Java 5

myList.Add (33);

In this example we adding an integer object to myList, but autoboxing handle the wrapping of the integer.

Catching an Expression (try and catch):

When an exception occurs, Exception handling works by transferring the execution of a program to an appropriate exception handler. For example call a method that happen

For example, If you try to call a method that takes a integer but the parameter is a String, execution of that method will stop, and code that we wrote to deal with this situation will be run. Therefore we need to tell Java Virtual Machine (JVM) what code to execute when certain exception happens. To deal with this situation we use the try and catch keywords. Try is also called as guarded region since it is used to deal with a block of code in which execution may occur. One or more catch keyword that match a specific exception (or group of exceptions) to a block of code that handle it




//first line of guarded region

//try keyword catches the exception that might occur in code execution

} catch (MyFirstException)


//code to handle this exception

//next line of exception handler


catch (MySecondException)


//code to handle this exception


Some unguarded code begins here...

String class:

Each character in java is a 16-bit Unicode character.

In Java, Strings are objects. Just like other objects, we can create a instance of a string with the 'new' keyword.

String s = new String ( );

Above code create a new object of class String and assign it to the reference variable s.

Assume String valve is

s= "qwerty";

We can write code in more efficient manner as

String s= new String ("qwerty");

The code creates a new String object with a valve of "qwerty" and assigns it to a reference variable s.

String Tokenizing:-

The process of taking big pieces of data, breaking them into little pieces and storing the little pieces in variable is called as Tokenizing. In the process of tokenizing is reading a delimited file in order to get the content of the file moved into useful places like objects, arrays or collections. For instance take a piece of data and tokenize it using a couple of different delimiters.

Source: "ab, cd5d, 6x, z43"

If the delimiter is a comma, then our five token will be



6 xs


In general, when we tokenize source data, the delimiter themselves are discarded and all that we are left with tokens.

Tokenizing with String. split():-

In the String class split () method takes a regex expression as its arguments and returns a String array populated with the tokens produced by the split process. For example the following program uses arg [0] to hold a source string, and args [1] to hold the regex pattern to use.

Unified Modelling Language Diagrams

The unified modelling language allows the software engineer to express an analysis model using the modelling notation that is governed by a set of syntactic semantic and pragmatic rules.

A UML system is represented using five different views that describe the system from distinctly different perspective. Each view is defined by a set of diagram, which is as follows.

User Model View

This view represents the system from the user's perspective.

The analysis representation describes a usage scenario from the end-users perspective.

Structural model view

In this model the data and functionality are arrived from inside the system.

This model view models the static structures.

Behavioural Model View

It represents the dynamic of behavioural as parts of the system, depicting the interactions of collection between various structural elements described in the user model and structural model view.

Implementation Model View:- In this the structural and behavioural as parts of the system are represented as they are to be built.

Environmental Model View

In this the structural and behavioural aspects of the environment in which the system is to be implemented are represented


Principle of working of UELBook:

A member enters the UELBOOK and register by using UEL ID and password.

Member can login using the ID and password. I the member login using incorrect Id or Password then output will be


If User Id and Password are correct then member can access the UELBook.

Member can access the method available in UELBook.

By Passing the ID, members can retrieve the Surname, First Name and Last Name.

Members can add Friends by passing ID of their friends.

Member can retrieve the list of friends, Friends of Friends, Friends of Friends without repetition by passing their ID as a parameter.

Member can create group or communities to the UELBook by passing ID and group name.

Member can retrieve list of groups present in UELBook.

Members can add Group by passing Id and group name as parameter

Member can get List of People in the group by passing group name as the parameter.


Required Hardware:

Pentium IV processes architecture

128 MB RAM.

20 MB Hard Disk Space

Required Software:

Eclipse IDE



NETBEANS 6.7.1:-

click on file -> import Project->eclipse project->

Click on "import project from work place", and then browse to file location.

In "project to import " window click Coursework, click on "Finish" button.

Click on Course work , then click on debug ->debugs Project (course work).

Then project will be start running.


Conclusion: I feel that course work is little bit difficult but I learned many things like how to use different type of IDE's , and there feature's , specification .