Showing posts with label Difference With Java. Show all posts
Showing posts with label Difference With Java. Show all posts

Thursday, 18 August 2011

Unicode vs ASCII




Unicode and ASCII both are standards
for encoding texts. Uses of such standards are very much important all
around the world. Code or standard provides unique number for every
symbol no matter which language or program is being used. From big
corporation to individual software developers, Unicode and ASCII have
significant influence. Communication
between different regions in the world was difficult but this was
needed in every time. Recent easiness in communication and development
of a unique platform for all people in the world is the result of
inventing some universal encoding system.


Unicode


Development of Unicode was coordinated
by a non-profit organization Unicode Consortium. Unicode is most
compatible with different language like Java, XML, Microsoft .Net etc.
Symbolic figure or glyptic art are greatly available due to modification
of character shape which is done using some mechanism adopted by
Unicode. Invention of Unicode has brought major renovation in texture,
graphics, themes etc. Natural numbers or electrical pulse is used to convert a text or picture and they are easy to transmit through different networks.


• Recent version of Unicode consist more than 109000 characters, charts for visual reference, encoding methodology, standard for encoding, collation, two-way display, depicting etc.


• UTF-8 is one of the widely used encodings.


• Unicode consortium
consists of world leading software and hardware companies like Apple,
Microsoft, Sun Microsystems, Yahoo, IBM, Google Oracle Corporation.


• First book was published by the consortium in 1991 and latest Unicode 6.0 published in 2010.


ASCII


Short form of American Standard Code for
Information Interchange is ASCII. Encoding of that system is based on
ordering the English alphabet. All modern data encoding machines support
ASCII as well as other. ASCII was first used by Bell data services as a
seven bit Tele-printer. Use of binary system had brought tremendous
change in our personal computing. Personal Computer as we see now is the
boon of using binary language which was used as core things for
encoding and decoding. Various languages later created and adopted are
based on it. As binary system makes the PC more comfortable and user
friendly for all, similarly ASCII is being used for making easiness in
communicating. 33 characters are non-printing, 94 printing characters
and space altogether makes 128 characters which are used by ASCII.


• It allows 128 characters.


• WWW or World Wide Web used ASCII as character encoding system but now ASCII is superseded by UTF-8.


• Short passage was encoded by early ASCII.


• ASCII-code order is different from traditional alphabetical order.








Difference between Unicode and ASCII


• Unicode is an expedition of Unicode Consortium to encode every
possible languages but ASCII only used for frequent American English
encoding. For example, ASCII does not use symbol of pound or umlaut.


• Unicode require more space than ASCII.


• Unicode use 8, 16 or 32 bit characters based on different presentation while ASCII is seven-bit encoding formula.


• Many software and email can’t understand few Unicode character set.


• ASCII only supports 128 characters while Unicode supports much more characters.

Though different variations appear among Unicode and ASCII but both
are very much essential in development of web based communication.

SQL vs PL SQL




SQL (Structured Query Language) is
the standard language to write entry relational databases. SQL is simple
statements, which allows to retrieve, insert, delete, update records as
user needs. Simply it is data oriented language for selecting and
manipulating set of data. PL SQL (Procedural Language/Structured Query
Language) is a procedural extension language for data entry and
manipulation by Oracle.


“PL/SQL, Oracle’s procedural extension of SQL, is an advanced fourth-generation programming
language (4GL). It offers modern features such as data encapsulation,
overloading, collection types, exception handling, and information
hiding. PL/SQL also offers seamless SQL access, tight integration with
the Oracle server and tools, portability, and security.”


SQL


Structured query language (SQL)
pronounced as “sequel” is a database computer language designed for
managing data in relational database management systems (RDBMS), and
originally based upon relational algebra.


Basic scope of SQL is to insert data and
perform update, delete, schema creation, schema modification and data
access control against databases.


SQL has elements, sub-divided into the followings:


Queries
– Retrieve data, based on specific criteria. There are few keywords
which can be used in queries. (Select, From, Where, Having, Group by and
order by)


e.g: SELECT * FROM table1 WHERE column1 > condition ORDER BY column2;


Statements – That may control transactions, program flow, connections, sessions, or diagnostics


Expressions – That can produce either;


Scalar values


Tables consisting of columns and rows of data


Predicates -Specify conditions that can be evaluated to SQL Boolean (true/false/unknown)


Clauses – Constituent components of statements and queries


PL/SQL


PL/SQL (Procedural Language/Structured
Query Language) is Oracle Corporation’s procedural extension language
for SQL and the Oracle relational database. PL/SQL supports variables,
conditions, loops, arrays, exceptions. PL/SQL essentially code
containers can be complied in to the oracle databases. Software
developers can therefore implant PL/SQL units of functionality into the
database straight.


PL/SQL program units can be defined as follows:


Anonymous blocks


Forms the basis of simplest PL/SQL code


Functions


Functions are a
collection of SQL and PL/SQL statements. Functions execute a task and
should return a value to the calling environment.


Procedures


Procedures are alike
to Functions. Procedures also can be executed to perform work.
Procedures cannot be used in a SQL statement, can return multiple
values. In addition, functions can be called from SQL, while procedures
cannot.


Packages


Use of packages is
re-using of code. Packages are groups of theoretically linked Functions,
Procedures, Variable, PL/SQL table and record TYPE statements,
Constants & Cursors etc… Packages usually have two parts, a
specification and a body


Two advantages of packages include:


Modular approach, encapsulation of business logic


Using packages variables can declare in session levels


Types of variables in PL/SQL


Variables


Numeric variables


Character variables


Date variables


Data types for specific columns


Difference between SQL and PL/SQL


SQL is data oriented language for selecting and manipulating data but PL SQL is a procedural language to create applications.


SQL executes one statement at a time whereas in PL SQL block of code could be executed.


SQL is declarative where as PL SQL is procedural.


SQL is used to
write Queries, Data Manipulation Language (DML) and Data Definition
Language (DDL) whereas PL SQL is used to write Program blocks, Triggers,
Functions, Procedures, and Packages.


Recap:


SQL is structured query language. In SQL
various queries are used to handle the database in a simplified manner.
PL/SQL is procedural language contains various types of variable,
functions and procedures. SQL allows developer to issue single query or
execute single insert/update/delete at a time, while PL/SQL allows
writing complete program to get done several
selects/inserts/updates/deletes at a time. SQL is simple data oriented
language while PL/SQL programming language.

Procedures vs Functions in Programming




Procedures and Functions in
programming, allow programmers to group instructions together in a
single block and it can be called from various places within the
program. The code becomes easier to understand and more compact. By
performing the modifications in a single place, the whole code will get
affected. With the help of functions and procedures; a linear and long
code can be divided into independent sections. They provide more
flexibility to the coding of various programming languages and
databases.


What are functions?


Functions are capable of accepting
parameters which are also known as arguments. They carry out the tasks
according to these arguments or parameters and return values of given
types. We can explain it better with the help of an example: A function
accepts a string as a parameter and returns the first entry or record
from a database. It takes into account the content for a specific field
that begins with such characters.


The syntax of function is as follows:


CREATE OR REPLACE FUNCTION my_func


(p_name IN VARCHAR2 := ‘Jack’) return varchar2 as begin … end


What are procedures?


Procedures can accept the parameters or
arguments and they carry out tasks as per these parameters. If a
procedure accepts a string as a parameter and it gives out a list with
records in database for which content of a specific field begin with
such characters.


The syntax of procedures is as follows:


CREATE OR REPLACE PROCEDURE my_proc


(p_name IN VARCHAR2 := ‘Jack’) as begin … end


Mainly, there are two ways by which a
parameter is passed in functions and procedures; by value or by
reference. If parameter is passed by a value; the modification is
affected within the function or procedure without affecting the actual
value of it.


On the other hand, if the parameters are
passed by references; the actual value of this parameter will be
changed wherever it is called within the code as per the instructions.






Difference between procedures and functions


• When the parameter is passed into the procedure; it does not return any value whereas a function always returns a value.


• One of the major differences in both of them is that procedures are
not used in databases whereas functions play an important role in
returning values from a database.


• Procedures are capable of returning multiple values and the functions are able to return limited values.


• DML operations can be used in stored procedures; however, they are not possible in functions.


• Functions can return only one value and it is mandatory whereas procedures can return n or zero values.


• In functions, error handling cannot be done whereas it can be performed in stored procedures.


• Input and output parameters can be passed in procedures whereas in case of functions; only input parameters can be passed.


• Functions can be called from procedures whereas it is not possible to call a procedure from a function.


• Transaction management can be considered in procedures and it cannot be considered in case of functions.

UNIX vs LINUX




UNIX and LINUX are both open source operating systems. Open source means that the source code of the operating system can be inspected as well as improved. The UNIX operating system was developed before LINUX. There are certain differences between the two.


UNIX


The UNIX operating system was developed
in 1969 at Bell labs. Now, UNIX is owned by The Open Group which sees
its development. A single UNIX specification is published by this group.
There are many other operating systems that are similar to UNIX or
share its features. The operating systems called UNIX-like.


Generally, network servers or
workstations have UNIX installed on them. UNIX served as a backbone of
early internet and today, it plays an important part in the functioning
of it. It is a portable system that allows multiprocessing in a computer
and even multiple users can log in at the same time.


Text input was employed in early UNIX
systems and a hierarchical file system for storage was used. Since then,
the system has changed a lot but still some commands are same. The Open
Group purchased UNIX from Novell in 1994. There are number of other
kernels of operating system that are based on UNIX.


The most famous among these is the LINUX
kernel. Linus Torvalds made a free version of LINUX kernel in 1992. It
was released under the GNU license and it was a complete open source OS.
Other distributions of this popular kernel are Ubuntu, Red hat and Fedora.


LINUX


LINUX is UNIX-like and an open source
operating system. This operating system can be inspected and
improvements can be made as desired. Open source platforms have an added
advantage especially regarding security as programmers around the world
provide their creative inputs. Also, open source platforms can be
tested by computer programmers around the globe. It is not possible in
closed system like Microsoft Windows.


There are different iterations of the
LINUX kernel such as Ubuntu, Red hat and Fedora. Most of them have
common features but they have been tailored according to specific needs.


In 1991, Linus Torvalds made the LINUX operating system when he was just an undergraduate at the University
of Helsinki (Finland). Even now, he is improving the system with the
help of hackers and programmers. The licensing of this operating system
allows the user to copy as well as distribute it freely with the source
code.






Difference between UNIX and LINUX:


• The UNIX operating system is used in internet servers and workstations while LINUX is mostly used on personal computers.


• The UNIX operating system was developed at Bell labs while LINUX operating system is made by LINUX Torvalds.


• The LINUX operating system is based on the kernel of UNIX operating system.


• Although both the operating systems are open source but UNIX is relatively closed one as compared to LINUX.

Objects vs Classes




Objects and classes are used in object oriented programming languages. All object oriented programming languages such as C++, Java, .NET and others, employs objects and classes.


Objects


An object is defined as any entity that can be utilized by using commands in a programming language. Object can be a variable, value, data structure
or a function. In object oriented environment, object is referred to as
instance of a class. Objects and classes are closely related to each
other. In real world, the objects are your TV, bicycle, desk and other
entities. Methods are used to access the objects of a class. All the
interaction is done through the object’s methods. This is known as data
encapsulation. The objects are also used for data or code hiding.


A number of benefits are provided by the objects when they are used in the code:


• Ease of debugging –
The object can be easily removed from the code if there is some problem
due to it. A different object can be plugged in as a replacement of the
former one.


• Information hiding
– The code or internal implementation is hidden from the users when
interaction is done through object’s methods.


• Reuse of code – if
an object or code is written by some other programmer then you can also
use that object in your program. In this way, objects are highly
reusable. This allows experts to debug, implement task specific and
complex objects that can be used in your own code.


• Modularity – You
can write as well as maintain the source codes of objects in an
independent manner. This provides modular approach to programming.


Classes


A class is a concept used in object
oriented programming languages such as C++, PHP, and JAVA etc. Apart
from holding data, a class is also used to hold functions. An object is
an instant of a class. In case of variables, the type is the class
whereas the variable is the object. The keyword “class” is used to
declare a class and it has the following format:


class CLASS_NAME


{


AccessSpecifier1:


Member-1;


AccessSpecifier2:


Member-2;




} OBJECT_NAMES;


Here, the valid identifier is CLASS_NAME
and the names for objects are represented by OBJECT_NAMES. The benefit
of objects include information hiding, modularity, ease in debugging and
reuse of the code. The body contains the members that can be functions
or data declarations. The keywords for access specifiers are public,
protected or private.


• The public members can be accessed anywhere.


• The protected members can be accessed within same classes or from friend classes.


• The private members can be accessed only within the same class.


By default, the access is private when the class keyword is used. A class can hold both data and functions.







Objects vs. Classes


• An object is an instant of a class. A class is used to hold data and functions.


• When a class is declared, no memory is
allocated but when the object of the class is declared, memory is
allocated. So, class is just a template.


• An object can only be created if the class is already declared otherwise it is not possible


Integer vs Pointer




The terms integer and pointer are used in most of the programming
languages. In computer programming languages, integer is referred as
any data type that represents a subset of mathematical integers whereas
pointers are defined as a type whose value points to or refers directly
to another value that is stored somewhere else in computer’s memory
using the address of the value.


Integer


In computer programming languages, an
integer is a data type that represents subset of mathematical integers.
The value of datum that has an integral part is the mathematical integer
to which it corresponds. The value is stored in the memory of computer
in this way by representing the datum. The integral types can be signed
or unsigned. Signed means they can represent negative integers and
unsigned mean they can represent non-negative integers.


A string of bits is the most common way
of representing a positive integer. This is done by using the binary
numeral system. There is a variation in the order of bits. The precision
or width of an integer type represents the number of bits.


In binary numeral system, the negative
numbers can be represented by three ways. This can be done by one’s
complement, two’s complement or sign-magnitude. However, there is
another method to represent integers and it is called binary-coded
decimal. But this method is rarely used these days.


Different integral types are supported
by different CPUs. Both signed as well as unsigned types are supported
by different hardware but there are some fixed width sets.


Pointer


In computer programming language,
a pointer is defined as the data type whose value points to or directly
refers to another value that is stored somewhere else in the memory of
the computer. Pointers takes place of general
purpose registers in case of high level languages whereas in low level
language such as machine code or assembly language, it is done in
available memory. A location in the memory is referenced by the pointer.
A pointer can also be defined a less subtracted or simple
implementation of more abstracted data type. Pointers are supported by
different programming languages but there are some restrictions on the
use of pointers in some languages.


Performance can be improved
significantly in case of repetitive operations such as lookup tables,
tree structures, strings and control tables. In procedural programming,
pointers are also used in holding addresses of entry points. However, in
object oriented programming, pointers are used to bind methods in
functions.


Although pointers are being used to
address the references but they can be applied more properly to data
structures. There are certain risks that are associated with pointers
because they allow protected as well as unprotected access to memory
addresses of the computer.

C vs C++




C and C++ are both programming
languages. C is a procedural programming language whereas C++ is an
object oriented programming language. There were certain drawbacks in
the C language. That is why, C++ was developed.

The C language


C is a computer programming language developed in 1972 at Bell Labs. It was mainly designed to be used with the UNIX operating system.
Apart from developing system software, C language is also used to
develop portable application software. Structural programming is
provided by the C language and it allows recursion as well as lexical
variable scope. Unintended operations are prevented by static type
system.


Functions contain all the executable code on the C language and the
parameters of the functions are passed by value. Pointer values are used
when functions parameters are passed by reference. To terminate a
statement, semicolon is used.


Following are the characteristics of the C language:



• Ad-hoc run time polymorphism is supported by data and function pointers.


• Reserved keywords are small.


• A wide variety of compound operators such as ++, -=, += etc.


• Conditional compilation, file inclusion of source code and a macro definition preprocessor.

A set of functions are used in C language. Each program in C language is executed in a function called “main function.”


C++ Language


C++ is also a computer programming language. C++ is a high level and
object oriented language. C++ is the most commonly used among all
programming languages. C++ was developed at Bell Laboratories and it
termed as the enhanced version of C language. The features of C++
language include templates, classes, operator overloading and virtual
functions. Exception handling and multiple inheritances were also
introduced in C++. As compared the C language, more type checking is
available in C++.


As it is considered as the enhanced version of C language, most of
the features of C language are maintained in C++. Even the C++ compilers
are able to run programs created in C. However, some code written in C
may be incompatible with C++ compilers.


C++ was originally developed for UNIX system. The code written in C++
is reusable which means that modification can be done in the code
without changing it. C++ is portable also which means it is independent
of operating system or it does not require specific hardware.


Class is another important feature introduced in C++. The code can be
organized with the help of classes. By using classes, bugs can be
removed as well as corrected easily.






Difference between C and C++
• C is a procedural programming language whereas C++ is an object oriented programming language.


• C++ introduced the concept of polymorphism, inheritance overloading whereas these are not present in C language.


• Object oriented approach such as objects and classes is used in C++ language.


• Although most of the C programs can be compiled using C++ compilers but still some programs may be incompatible.

Get vs Post




If the form data is encoded with the URL that
is requested from the server, it is termed as Get, whereas, if the form
data is sent within the body of the message, it is termed as the Post.
When you do not have any additional information with the URL, this form
is being used.

The HTML pages that we read in our web browser are of static in
nature. These are the static documents and when we interact actively
with a web page, you have to send the data back to sever in anyway. This
is achieved with the use of forms and there are two methods by which
you can use a form; Get and Post. By using the form, the data is encoded
to send it back to the server. Now, what is the exact difference
between Get and Post?


If the data is encoded with the URL that is requested from the
server, it is termed as Get according to the HTML specifications. The
form data is separated from the URL by the application that receives the
data. After parsing out the URL and form data, it is used as input for
the query. If you see a long tail of values and variables tied onto the
end of a web URL, you can understand that you are dealing with the Get
query. With all the query information, you can bookmark the whole URL if
you are working with the Get request. So you can definitely see the
results of the query when you open up the bookmark again.


If the form data is sent within the body of the message, it is termed
as the Post. When you do not have any additional information with the
URL, this form is being used. The Post cannot be cached in the browser history
of the user when compared to the Get. This condition arises the
situation that page have to resubmit the information to the web server.
You night have encountered with this situation quite often.


It is often recommended that you have to use Get when you develop a
form and only in certain conditions you have to use Post. If any of the
variable crash the browser or if it makes the URL too long, you can use
Post form. There are several advantages of using Post as it is the
better form you can use if you need to make the functionality of your
application hidden or less visible to the other users. But this is not a
promise of security as anyone can understand the variables you use from the source code of your application.


The major differences between Get and Post can be outlined as:



  • Visibility


This is the fundamental difference between the Get and Post methods.
The Get request is appended to the URL as is separated by a question
mark. The Post request can’t be seen as it is encapsulated in the HTTP
body.



  • Performance


It is relatively easy to create a Get request and it is much faster
than the Post request. But the Post request takes time in encapsulation
process.



  • Data type


Since Get request is sent through the URL, it can be of the text
format only. But there is no such restriction in the case of Post and it
can carry both binary and text data.



  • Data set


“Enctype” attribute with value can be used with the Post requests while the Get requests can only use the ASCII characters.


If the form causes no side-effects, the “GET” method can be used. Most of the databases are ideal for the use of GET method.

JSP vs Servlets




A Servlet is a server side software
component written in Java and runs in a compatible container environment
known as a Servelt container (like Apache Tomcat). Servlets are
predominantly used in implementing web applications
that generate dynamic web pages. They can however generate any other
content type like XML, text, images, sound clips, PDF, Excel files
programmatically.

A Servlet written to generate some HTML may look like this:


public class MyServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


PrintWriter w = response.getWriter();

w.write(“<html>”);

w.write(“<body>”);


Date d = new Date();

w.write(d.toString());

w.write(“</body>”);

w.write(“</html>”);

}

}



The code above contains a mixture of
HTML and Java source code. Such is not very readable and maintainable.
JSP which stands for JavaServer Pages provides a better alternative. For
example, the following is a fragment of JSP code that results in
identical output:

<%@page import=”java.util.Date”%>

<html>

<body>

<%= new Date().toString() %>

</body>

</html>



Web page authors find JSP easier to
write and maintain. JSP files are however translated into Servlets by a
Servlet container at the time JSP files are first accessed. However, business logic writers find Servlets to be easier to work with.


A request received by a web application
should trigger the execution of some business logic and then generate a
resultant web page as the response. In modern day web applications,
controlling the overall request processing cycle is mostly handed by
Servlets. As the last stage in processing a request, such a Servlet
generally hands over the responsibility of generating the dynamic HTML
to a JSP.

JDK vs JRE


JDK stands for the Java Developer Kit whereas JRE stands for the Java Runtime Environment.
JRE is what is needed to run Java applications. Bundled within is an implementation of the Java Virtual Machine (JVM).
JDK includes JRE and many other Java application development tools. For example, the Java compiler (javac) is included only in JDK.
If you want to run Java software, you may simply live with JRE. The JRE installation file size is also smaller.
If you are a Java software developer, you need to use JDK. As said, if you download and install JDK, you need not install JRE since JRE is included within JDK.

Java vs J2EE


Java is a programming language and a platform to develop and run software applications. It comes in different flavors:
  1. Java Standard Edition (Java SE)
    This is the plain vanilla version of Java. You can implement any software application with it. Java SE has a large library of code which includes many reusable software functions. Java EE and Java ME described below are built on top of Java SE.

  2. Java Enterprise Edition (Java EE)
    This flavor of Java builds on Java SE. Java EE contains additional libraries of code and development tools that are uniquely useful in developing business applications.

  3. Java Micro Edition (Java ME)
    Than being yet another extension to Java SE, this is in fact a reduced version of Java SE and an associated library of software that addresses the unique needs of Java applications that should run on limited capability devices like mobile phones and PDAs.

When we simply say “Java”, we mostly mean Java Standard Edition.
J2EE refers to the first version of Java Enterprise Edition.
Java (i.e. Java SE) does not mandate you to use specific patterns or architectures in implementing applications. It is the plain version of Java and you can implement your application in any preferred way.
Java EE however describes an overall architecture that your business application should adhere to. Java EE also includes best practices and guidelines that you may follow in addressing the unique requirements of business applications.

Java vs JavaScript


Java and JavaScript are programming languages. Java is an object oriented programming language whereas JavaScript is more of a scripting language. Both can be used to make web pages more interactive. However, Java is also used to develop server side applications and standalone programming.
Java
Java is an object oriented programming language. In early 1990s, Sun Microsystems developed the Java language. Initially, it was designed to make small programs for the web browser called applets. But later on, Java was used to create applications based on e-commerce.
There are five main features of Java language:
• Provides more flexibility to develop software applications because of object oriented approach.
• Easy to use as it combines the best properties of other programming languages.
• Allows code written in Java to run on different platforms or Java code is independent of platform.
• The code from the remote source can be executed securely.
• Built-in support for computer networks.
Java also supports automated memory management model that allows developers to get rid of the time consuming method called manual memory management. Programmers can easily do this by implementing automatic garbage collection. But according to some people, Java is slow as well as consumes more memory than other programming languages such as C++.
JavaScript
JavaScript is also a programming language which is used to make web pages more dynamic as well as interactive. Constant downloads from the server are not required in case of JavaScript as it runs on the user’s computer. JavaScript is different from the Java programming language.
Most modern day web browsers have built-in JavaScript. However, JavaScript based web pages can run only if JavaScript is enabled on the web browser and the browser supports it. JavaScript is enabled in most browsers by default.
No special program is required in order to write code in JavaScript as it is an interpreted language. You can use any text editor such as Notepad in order to write JavaScript code. You can also use other text editor that colorizes the different codes making it easier to detect any error.
JavaScript is different from HTML because JavaScript is used to create more dynamic web pages while HTML is a markup language that is used to create static content on the web page.
You can insert the JavaScript code in a HTML file by using the <script> tag. But if you want to use the script in different pages of the website then you can save the scripts in different files with .js extension.


Difference between Java and JavaScript
• Java is an object oriented programming language whereas JavaScript is more of a scripting language.
• JavaScript is used to make the web pages more interactive. However, Java can be used not only to make interactive web pages but can also be used to create server side applications and standalone programming.
• Java uses the concept of classes and objects that makes reuse of the code easier but there is no such thing in JavaScript.
• Java exhibits the properties like inheritance, data encapsulation and polymorphism whereas JavaScript does not.

Java vs C language


Java and C are both computer programming languages. Both are used to develop software applications. Java is used to create application based on e-commerce and applets while C language is used to create system software.
C language
In 1972, the C language was developed at the Bell labs and it was designed to work with the UNIX operating system. The C language is not only used to develop system software rather it is also used to develop portable application software. The C language employs structural programming and it also allows lexical variable scope as well as recursion. Static type system helps in preventing unintended operations.
All the executable code in C is contained inside the functions and their parameters are passed by value. When parameters are passed by functions, pointer values are used. Semicolon is used in order to terminate a statement. A function called “Main function” is the one in which the execution of the program is done.
Following are the features of C language:
• A wide variety of compound operators such as ++, -=, += etc.
• Ad-hoc run time polymorphism is supported by data and function pointers.
• Conditional compilation, file inclusion of source code and a macro definition preprocessor.
• Reserved keywords are small.
JAVA
Java is a purely object oriented programming language and it was developed by Sun Microsystems in 1990s. Although it was designed for small programs that run on the browser called applets but later on, it is also being used to create e-commerce applications.
There are five main features of Java language:
• Built-in support for computer networks.
• The code from the remote source can be executed securely.
• Easy to use as it combines the best properties of other programming languages.
• Provides more flexibility to develop software applications because of object oriented approach.
• Allows code written in Java to run on different platforms or Java code is independent of platform.
There is no such thing as manual memory management in Java rather it supports automatic memory management. This saves a lot of time of programmers as they don’t need to free memory manually rather this is achieved by the implementation of automatic garbage collection. Some programmers think that Java consumes more memory as compared to C and C++ programming languages.


Difference between Java and C language
• Java is an object oriented programming language while C is a procedural or structural language.
• Java was developed by Sun Microsystems while C language was developed at Bell labs.
• Java is used to create applets and e-commerce applications based on the web while c language is used to create system software and applications.
• Java employs the concept of objects and classes while C language does not support them.
• Java supports automatic garbage collection while C language does not even though some programmers believe that Java consumes more memory.

Java vs C++

Java vs C++

Java and C++ are both object oriented programming languages. Software applications are developed using these applications. Applications based on E-commerce are developed using Java language while C++ language is used towards development of system software.
JAVA
Java is an object oriented programming language. In 1990s, it was developed by Sun Microsystems. Although, this language was mainly designed for the development of Applets that are small applications that run on the browser but later on it is also used to developed applications based on e-commerce.
Following are the features of Java programming language:
• Secure execution of the code from a remote server.
• The code written in Java can run on different platforms or it is platform independent.
• Built-in support for computer networks.
• Allows flexible development of software applications because modular or object oriented approach.
• Java language includes all the best features of other programming languages which make its use easier as compared to other programming languages.
Another important feature of this language is the way it handles the memory. It supports automatic memory management rather than manual memory management. Automatic memory management means that automatic garbage collection is implemented in Java so that programmers need not to worry about freeing the memory. However, according to some programmers, more memory is consumed by Java language as compared to other programming languages such as C and C++.
C++
C++ is a high level object oriented programming language. Among all programming languages, C++ is the most commonly used. It is termed as the enhanced version of C language and it was also developed at Bell Laboratories. Features like virtual functions, operator overloading, templates and classes are supported by C++. This language also introduced the concept of multiple inheritances as well as exception handling. More type checking is available in C++ as compared to C language.
C++ includes all the main features that were present in C language. Even the compliers in C++ are able to run the code which is written in C language. But there may be some that may not be able to execute in C++.
The C++ language was mainly designed for the UNIX operating system. C++ also allows code reusability. It means that programmers can easily modify the code without changing it. It also provides portability that means it does not require specific hardware and operating system.
C++ language also introduced the concept of classes. By using classes, the written code can be organized easily. Classes also help in removal and correction of bugs in an easier manner.


Difference between Java and C++ language:
• According to some experts, Java is pure object oriented programming language while C++ is object based programming language.
• The code written in Java can run on different platforms whereas this not possible with C++.
• Java is mainly used for developed applets and e-commerce based applications while C++ is used for developing system software.

Similarities and Differences between Java and C++


Introduction

This lesson introduces you to Java programming by presenting some of the similarities and differences between Java and C++.

An Initial Word about Java and C++

Please see the material in the Preface, which discusses the relationship between Java and C++ insofar as this course of study is concerned. In general, students in Prof. Baldwin's Java classes are not required to have any knowledge of C++.

Similarities and Differences

This list of similarities and differences is based heavily on The Java Language Environment, A White Paper by James Gosling and Henry McGilton http://java.sun.com/doc/language_environment/ and the soon-to-be published book, Thinking in Java by Bruce Eckel, http://www.EckelObjects.com/. At least these were the correct URLs at one point in time. Be aware, however, that the web is a dynamic environment and the URLs may change in the future.
Java does not support typedefs, defines, or a preprocessor. Without a preprocessor, there are no provisions for including header files.
Since Java does not have a preprocessor there is no concept of #define macros or manifest constants. However, the declaration of named constants is supported in Java through use of the final keyword.
Java does not support enums but, as mentioned above, does support named constants.
Java supports classes, but does not support structures or unions.
All stand-alone C++ programs require a function named main and can have numerous other functions, including both stand-alone functions and functions, which are members of a class. There are no stand-alone functions in Java. Instead, there are only functions that are members of a class, usually called methods. Global functions and global data are not allowed in Java.
All classes in Java ultimately inherit from the Object class. This is significantly different from C++ where it is possible to create inheritance trees that are completely unrelated to one another.
All function or method definitions in Java are contained within the class definition. To a C++ programmer, they may look like inline function definitions, but they aren't. Java doesn't allow the programmer to request that a function be made inline, at least not directly.
Both C++ and Java support class (static) methods or functions that can be called without the requirement to instantiate an object of the class.
The interface keyword in Java is used to create the equivalence of an abstract base class containing only method declarations and constants. No variable data members or method definitions are allowed. (True abstract base classes can also be created in Java.) The interface concept is not supported by C++.
Java does not support multiple inheritance. To some extent, the interface feature provides the desirable features of multiple inheritance to a Java program without some of the underlying problems.
While Java does not support multiple inheritance, single inheritance in Java is similar to C++, but the manner in which you implement inheritance differs significantly, especially with respect to the use of constructors in the inheritance chain.
In addition to the access specifiers applied to individual members of a class, C++ allows you to provide an additional access specifier when inheriting from a class. This latter concept is not supported by Java.
Java does not support the goto statement (but goto is a reserved word). However, it does support labeled break and continue statements, a feature not supported by C++. In certain restricted situations, labeled break and continue statements can be used where a goto statement might otherwise be used.
Java does not support operator overloading.
Java does not support automatic type conversions (except where guaranteed safe).
Unlike C++, Java has a String type, and objects of this type are immutable (cannot be modified). Quoted strings are automatically converted into String objects. Java also has a StringBuffer type. Objects of this type can be modified, and a variety of string manipulation methods are provided.
Unlike C++, Java provides true arrays as first-class objects. There is a length member, which tells you how big the array is. An exception is thrown if you attempt to access an array out of bounds. All arrays are instantiated in dynamic memory and assignment of one array to another is allowed. However, when you make such an assignment, you simply have two references to the same array. Changing the value of an element in the array using one of the references changes the value insofar as both references are concerned.
Unlike C++, having two "pointers" or references to the same object in dynamic memory is not necessarily a problem (but it can result in somewhat confusing results). In Java, dynamic memory is reclaimed automatically, but is not reclaimed until all references to that memory become NULL or cease to exist. Therefore, unlike in C++, the allocated dynamic memory cannot become invalid for as long as it is being referenced by any reference variable.
Java does not support pointers (at least it does not allow you to modify the address contained in a pointer or to perform pointer arithmetic). Much of the need for pointers was eliminated by providing types for arrays and strings. For example, the oft-used C++ declaration char* ptr needed to point to the first character in a C++ null-terminated "string" is not required in Java, because a string is a true object in Java.
A class definition in Java looks similar to a class definition in C++, but there is no closing semicolon. Also forward reference declarations that are sometimes required in C++ are not required in Java.
The scope resolution operator (::) required in C++ is not used in Java. The dot is used to construct all fully-qualified references. Also, since there are no pointers, the pointer operator (->) used in C++ is not required in Java.
In C++, static data members and functions are called using the name of the class and the name of the static member connected by the scope resolution operator. In Java, the dot is used for this purpose.
Like C++, Java has primitive types such as int, float, etc. Unlike C++, the size of each primitive type is the same regardless of the platform. There is no unsigned integer type in Java. Type checking and type requirements are much tighter in Java than in C++.
Unlike C++, Java provides a true boolean type.
Conditional expressions in Java must evaluate to boolean rather than to integer, as is the case in C++. Statements such as if(x+y)... are not allowed in Java because the conditional expression doesn't evaluate to a boolean.
The char type in C++ is an 8-bit type that maps to the ASCII (or extended ASCII) character set. The char type in Java is a 16-bit type and uses the Unicode character set (the Unicode values from 0 through 127 match the ASCII character set). For information on the Unicode character set see http://www.stonehand.com/unicode.html.
Unlike C++, the >> operator in Java is a "signed" right bit shift, inserting the sign bit into the vacated bit position. Java adds an operator that inserts zeros into the vacated bit positions.
C++ allows the instantiation of variables or objects of all types either at compile time in static memory or at run time using dynamic memory. However, Java requires all variables of primitive types to be instantiated at compile time, and requires all objects to be instantiated in dynamic memory at runtime. Wrapper classes are provided for all primitive types except byte and short to allow them to be instantiated as objects in dynamic memory at runtime if needed.
C++ requires that classes and functions be declared before they are used. This is not necessary in Java.
The "namespace" issues prevalent in C++ are handled in Java by including everything in a class, and collecting classes into packages.
C++ requires that you re-declare static data members outside the class. This is not required in Java.
In C++, unless you specifically initialize variables of primitive types, they will contain garbage. Although local variables of primitive types can be initialized in the declaration, primitive data members of a class cannot be initialized in the class definition in C++.
In Java, you can initialize primitive data members in the class definition. You can also initialize them in the constructor. If you fail to initialize them, they will be initialized to zero (or equivalent) automatically.
Like C++, Java supports constructors that may be overloaded. As in C++, if you fail to provide a constructor, a default constructor will be provided for you. If you provide a constructor, the default constructor is not provided automatically.
All objects in Java are passed by reference, eliminating the need for the copy constructor used in C++.
(In reality, all parameters are passed by value in Java.  However, passing a copy of a reference variable makes it possible for code in the receiving method to access the object referred to by the variable, and possibly to modify the contents of that object.  However, code in the receiving method cannot cause the original reference variable to refer to a different object.)
There are no destructors in Java. Unused memory is returned to the operating system by way of a garbage collector, which runs in a different thread from the main program. This leads to a whole host of subtle and extremely important differences between Java and C++.
Like C++, Java allows you to overload functions. However, default arguments are not supported by Java.
Unlike C++, Java does not support templates. Thus, there are no generic functions or classes.
Unlike C++, several "data structure" classes are contained in the "standard" version of Java. More specifically, they are contained in the standard class library that is distributed with the Java Development Kit (JDK). For example, the standard version of Java provides the containers Vector and Hashtable that can be used to contain any object through recognition that any object is an object of type Object. However, to use these containers, you must perform the appropriate upcasting and downcasting, which may lead to efficiency problems.
Multithreading is a standard feature of the Java language.
Although Java uses the same keywords as C++ for access control: private, public, and protected, the interpretation of these keywords is significantly different between Java and C++.
There is no virtual keyword in Java. All non-static methods always use dynamic binding, so the virtual keyword isn't needed for the same purpose that it is used in C++.
Java provides the final keyword that can be used to specify that a method cannot be overridden and that it can be statically bound. (The compiler may elect to make it inline in this case.)
The detailed implementation of the exception handling system in Java is significantly different from that in C++.
Unlike C++, Java does not support operator overloading. However, the (+) and (+=) operators are automatically overloaded to concatenate strings, and to convert other types to string in the process.
As in C++, Java applications can call functions written in another language. This is commonly referred to as native methods. However, applets cannot call native methods.
Unlike C++, Java has built-in support for program documentation. Specially written comments can be automatically stripped out using a separate program named javadoc to produce program documentation.
Generally Java is more robust than C++ due to the following:
  • Object handles (references) are automatically initialized to null.

  • Handles are checked before accessing, and exceptions are thrown in the event of problems.

  • You cannot access an array out of bounds.

  • Memory leaks are prevented by automatic garbage collection.