Java Programming Language Development Computer Science Essay

Java is a programming linguistic communication developed by Sun Microsystems. It implements a strong security theoretical account, which prevents complied Java plans from illegitimately accessing resources on the system where they execute or on the web. Popular World-Wide-Web browsers, every bit good as some World-Wide Web waiters and other systems implement Java translators. These are used to expose synergistic user interfaces, and to script behaviour on these systems.

While execution jobs have opened security exposures in some Java translators ( Java Virtual Machines or JVM ‘s ) , the design of this linguistic communication makes it at least theoretically possible to put to death plan with sensible confidences about its Security, and in peculiar its ability to do injury.

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

Introduction to Computer Science utilizing Java

Java is a simple and yet powerful object oriented programming linguistic communication and it in many respects similar to C++ . Java originated at Sun Microsystems, Inc. in 1991. It was conceived by James Gosling, Patrick Nauhton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems, Inc. It was developed to supply a platform independent scheduling linguistic communication.

( Introduction to Java Programming, eight edition, 2007, by Y.Daniel Liang )

Platform independent

It unlikely many other programming linguistic communications including C and C++ when Java is complied, it s non compiled into platform specific machine, instead into platform independent byte codification. This byte codification is distributed over the web and interpreted by practical Machine ( JVM ) on whichever platform it being run.

Java Virtual Machine

What is the Java Virtual Machine? What is its function?

Java was designed with a construct for “ write one time and run everyplace ” . Java Virtual Machine plays the cardinal function in this construct. The JVM is environment in which Java plans execute. It is package that is implemented on top of existent hardware and operating system. When the beginning codification ( .java files ) is complied, it is translated into byte codifications and so placed into ( .class ) files. The JVM executes these byte codifications. So Java byte codifications can be through of as the machine linguistic communication of the JVM. A JVM executes these byte codifications. So Java byte codifications can be through of as the machine linguistic communication of the JVM. A JVM can either construe the byte codification one direction at a clip or the byte codification can be complied further for the existent microprocessor utilizing what is called a just-in-time compiler. The JVM must be implemented on a peculiar platform before compiled plans can run on that platform.

Object Oriented Programming

Since Java in an object oriented programming linguistic communication it has following characteristics:

Reusability of codification

Emphasis on informations instead than process

Datas in hidden and can non be accessed by external maps

Object can pass on with each other through maps

New informations and maps can be easy added Java has powerful characteristics. The followers are some of them:

Simple

Reclaimable

Portable ( Platform Independent )

Distributed

Robust

Secure

High Performance

Dynamic

Threaded

Interpreted

Object Oriented Programming is a method of execution in which plans are organized as concerted aggregation of objects, each of which represents an case of a category, and whose categories are all remembers of a hierarchy of categories united via heritage relationships.

( Object-Oriented Scheduling: From Problem work outing to Java, 1st edition, 2003, by Garrido, Jose. Ebrary Olympia College. )

OOP Concepts

Four rules of Object Oriented Programming are:

Abstraction

Abstraction denotes the indispensable features of an object that distinguish it from all other sorts of objects and therefore supply crisply defined conceptual boundaries, comparative to perspective of the spectator.

Encapsulation

Encapsulation is the procedure of compartmentalising the elements of an abstraction that constitute its construction and behaviour and encapsulation serves to divide the contractual interface of an abstraction and its execution.

Inheritance

Inheritance is the procedure by which one object acquires the belongingss of another object.

Polymorphism

Polymorphism is the being of the categories or methods in different signifiers or individual name denoting different executions.

Java is Distributed

It with extended set of modus operandis to manage TCP/IP protocols like HTTP and FTP Java can open and entree the objects across net via URLs.

Java is Multithreaded

The one of the powerful facets of the Java linguistic communication is that it let multiple togss of executing to run at the same time within the same plan. A individual Java plan can hold many different togss put to deathing independently and continuously. Multiple Java applets can run on the browser at the same clip sharing the CPU clip.

Java is Secure

Java was designed to let unafraid executing of codification across web. To do Java procure many of the characteristics of C and C++ were eliminated. Java does non utilize Pointers. Java plans can non entree arbitrary references in memory.

Garbage aggregation

Automatic refuse aggregation is another great characteristic of Java with which it prevents accidental corruptness of memory. Similar to C+ , Java has a new operator to apportion memory on the pile for a new object. But it does non utilize delete operator to liberate the memory as it is done in C++ to liberate the memory if the object is no longer needed. It is done automatically with refuse aggregator.

Java Applications

Java has evolved from a simple linguistic communication supplying synergistic dynamic content for web pages to a prevailing enterprise-enabled scheduling linguistic communication suited for developing important and critical applications. It is used for many types of applications including Web based applications, Financial applications, Bet oning applications, embedded systems, distributed endeavor applications, nomadic applications, Image processors, desktop applications and many more.

( Java Programming, 6th edition, 2011, by Cengage South-Western. )

Define Question 1

Method overloading is Java allows you to hold multiple methods holding the same name, every bit long as each method accepts different sets of statement types. In other words, in our illustration, it is legal to hold these two methods in the same category.

public String printString ( Stringing twine )

public String printSrting ( Stringing twine, int beginning )

This technique is called method overloading. The return value of the method is non taken into consideration. As such, these two methods must non be in the same category:

public int countRows ( int figure ) ;

public String countRows ( int figure ) ;

( Java Programming, 6th edition, 2011, by Cengage South-Western. )

Method Overloading is methods of the same name can be declared in the same category, every bit long as they have different sets of parametric quantity.

This is called “ Method Overloading ” .

Method overloading is normally used to make several method with the same name that perform the same and similar undertakings.

Using the Method Overloading

Public category MainClass {

Public void print ( int a ) {

System.out.println ( a ) ;

}

Public void print ( Stringing a ) {

System.out.println ( a ) ;

}

{ A method ‘s name with the types and sequence of the parametric quantities form the method ‘s signature.

( Java Programming, the easy way,1st edition,1999, by Robert. )

Answer for Question 1

Method Overloading

Method overloading consequences when two or more methods in the same category have the same name but different parametric quantities. Methods with the same name must differ in their types or figure of parametric quantities. This allows the compiler to fit parametric quantities and take the correct method when a figure of picks exist. Changing merely the return type is non plenty to overload a method, and will be a compile-time mistake. They must hold a different signature. When no method fiting the input parametric quantities is found, the compiler efforts to change over the input parametric quantities to types of greater preciseness. A lucifer may so be found without mistake. At compile clip, the right execution is chosen based on the signature of the method call.

Below is an illustration of a category Method Overloading.

public category overloading {

public inactive nothingness chief ( Stringing [ ] args )

{

System.out.println ( “ Square of whole number 7 is: ” + square ( 7 ) ) ;

System.out.println ( “ Square of dual 7.5 is: ” +square ( 7.5 ) ) ;

}

public inactive int square ( int num1 )

{

System.out.println ( “ Called square with int: “ + num1 ) ;

return num1*num1 ;

}

public inactive dual square ( dual num2 )

{

System.out.println ( “ Called square with dual: ” +num2 ) ;

return num2*num2 ;

}

}

( Miss Liza notes, 2010, Java Programming, Method Overloading )

End product

— — — — — — — — — — Configuration: & lt ; Default & gt ; — — — — — — — — — —

Called square with int: 7

Square of whole number 7 is:49

Called square with double:7.5

Square of dual 7.5 is:56.25

Procedure completed.

Naming conventions are an of import facet of any development undertaking, but coming up with alone names can be slightly boring. One manner to simplify the job is to recycle method names via overloading. Overloading is the ability to hold a category that has multiple methods with the same name that are differentiated by the figure and type of statements passed into the method.

What ‘s in a name?

When delegating names to categories, methods, and member variables, it is of import to utilize names that are easy to understand. For illustration, making a category for specifying a overloading would take to an appropriate category name of overloading. Naming it a gibberish name like abcd would be valid Java codification but perfectly nonsensical to any coder working on the system in the hereafter. The overloading category has the undermentioned appellation:

public category overloading {

public inactive nothingness chief ( Stringing [ ] args )

{

System.out.println ( “ Square of whole number 7 is: ” + square ( 7 ) ) ;

System.out.println ( “ Square of dual 7.5 is: ” +square ( 7.5 ) ) ;

}

The codification listing declares a category called overloading, with two member variables of square. The names assigned to the member variables are correspondent to their usage, so it is easy to place what type of informations is stored in them. When developing the overloading category, we need to dwell these member variables when the object is created.

Object building

Making a new object case triggers the category ‘s builder method. The undermentioned codification utilizes a basic builder that accepts no statements:

public inactive int square ( int num1 )

{

System.out.println ( “ Called square with int: “ + num1 ) ;

return num1*num1 ;

}

The basic builder initializes the member variables with empty strings. Upon farther probe, it is discovered that frequently the objects are created with known names but sometimes merely the last name. You can utilize method overloading to make multiple method versions, but each has its ain method signature. The signature defines what parametric quantities are accepted by the method. For illustration, here ‘s the method signature for the old builder:

public inactive dual square ( dual num2 )

{

System.out.println ( “ Called square with dual: ” +num2 ) ;

return num2*num2 ;

}

}

This method can be overloaded to suit foremost and last names or merely the last name:

These two print methods end product the member variables, with one method accepting text to prepend to the end product and the other non.

Overloading is a powerful characteristic, but you should utilize it merely as needed. Use it when you really do necessitate multiple methods with different parametric quantities, but the methods do the same thing. That is, do n’t utilize overloading if the multiple methods perform different undertakings. This attack will merely confound other developers who get a peep at your codification.

Define Question 2

Java cringle

A scheduling cringle is a control construction that allows a coder to put to death the same direction or group of instructions over and over until some status is met. All cringles have a basic construction to them, though there are many types:

The loop entry is the point at which the plan ‘s control enters the cringle and begins put to deathing the first instructions.

The loop trial at the beginning of the cringle takes over the plan control and determines whether the cringle can get down, repetition, or skip to the bids after the cringle.

The loop is a individual rhythm made through to loop, i.e. if the computing machine executes the cringle 12 times the cringle has 12 loops.

The expiration status is whatever is built in to the cringle to do the iteration to halt. The plan control exits the cringle and continues go outing whatever bids come after.

There are three chief classs ofA controlA flow statements ;

Choice statements: A if, if-else and switch.

Loop statements: A while, do-while and for.

Transportation statements: A interruption, continue, return, try-catch-finally and asseverate.

Answer for Question 2

/**

* @ ( # ) examplefor.java

*

*

* @ writer

* @ version 1.00 2011/3/30

*/

public category examplefor {

public inactive nothingness chief ( Stringing [ ] args )

{

int num=5 ;

make

{

int temp = num ;

for ( int I = num ; i & gt ; 1 ; Is — )

{

temp = temp*10+num ;

}

System.out.println ( temp ) ;

num — ;

}

while ( num & gt ; 0 ) ;

}

}

— — — — — — — — — — Configuration: & lt ; Default & gt ; — — — — — — — — — —

55555

4444

333

22

1

Procedure completed.

Conclusion & A ; Recommendation

Method Overloading

In a category, the construct of method overloading does non let the external user to be cognizant about the internal processing of the system

— It merely allows to user to utilize the different executions of same name collected together and respond suitably to the supplied parametric quantities to acquire the coveted end product.

— Method Overloading, allows the user to accomplish the compile clip polymorphism.

— Overloaded methods are ever the portion of the same category. These methods have the same name, but they may take different input parametric quantities.

— The statements passed to a overloaded method may differ in type or in figure, or both.

— Overloaded methods may hold the same or different return types.