Java
  Home arrow Java arrow Completing the Syntactic Comparison of...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 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: 4 stars4 stars4 stars4 stars4 stars / 5
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    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


       · Finally, here's the second segment of this series. Thanks for following this JAVA...
     

       

    JAVA ARTICLES

    - 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...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections

    Iron Speed
     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway