Java
  Home arrow Java arrow Completing the Syntactic Comparison of Java and C/C++
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Completing the Syntactic Comparison of Java and C/C++
By: Barzan "Tony" Antal
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 6
    2007-11-28


    Table of Contents:
  • Completing the Syntactic Comparison of Java and C/C++
  • Classes continued
  • Other Distinctions
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Completing the Syntactic Comparison of Java and C/C++
    ( Page 1 of 4 )

    This is the second half of the two-part series on the syntactic comparison of Java and C/C++. Before we begin, I’d like to encourage you to read its first part if by any chance you’ve missed it. It is called “Syntactic Comparison of Java and C/C++” and it’s published right here. You shouldn’t miss it because grasping the basics is crucial.

    In the first part I showed you the main differences as far as data types, classes, and some additional important details on the semantics of those two languages. Now we’re going to discuss more thoroughly the topics of classes, command line arguments, unconditional transfers of control (goto, labels, break, continue), and so forth.

    Moreover, before finishing this article I’ll point out the features that are present in C/C++ but missing from Java and vice versa. Furthermore, you might be expecting some kind of conclusion or final words at the end. I definitely won’t conclude that one is better than the other but I’m determined to give you my personal opinions regarding these two languages.

    Now the time has come for us to begin. Ready, Steady, Go!

    Classes

    I’ve mentioned in my previous article that a class is one of the most important concepts in Java. That’s because everything must take part of a class. This wasn’t fashionable with C/C++. Even though classes have critical importance in C/C++ too, they aren’t necessary. In Java they are required and everything happens around them.

    Should you desire to create global functions and use global variables, you are going to encapsulate everything inside a class. You do this by creating static methods and static data that ultimately are placed inside a class. Of course, encapsulation into multiple classes is possible too. Additionally, it is worth mentioning that there is a huge family of classes that has a so-called superclass (ancestor), the Object class.

    Java also has a long list of access modifiers that can be implemented to classes, constructors, methods, etc. Each of these has their very own rules according to which they can be implemented. For example, out of the following 3 modifiers only one should be used when declaring a method: private, public, protected; or methods that have modified as abstract or native should have no body.

    A final note on access modifiers is that they do not interfere with inheritance by prevention. On the other hand, they do affect which parts you can or cannot see within a subclass. Speaking of inheritance, another significant difference is that multiple inheritances aren’t allowed in Java. But there’s a so-called interface structure that is not a class but can inherit from a base class (superclass).

    However, there is a workaround by implementing multiple interfaces. An interface is a class that contains nothing but abstract methods. Hence, their body must be defined in the inherited classes.



     
     
    >>> More Java Articles          >>> More By Barzan "Tony" Antal
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT