• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java vs C++ question....

mobogasm

Golden Member
This Friday I have to take a "placement" exam for CSE at the university I was just accepted into. I took two quarters of C++ and have a handful of experience with it over two years of college. The placement exam is going to be on java (which I know nothing about) but I'm pretty sure it is rather similar to c++ in syntax for the most part. Do you think I will have any problems? I'm pretty sure it will be a pretty basic exam. Is is only three questions on "examining" a chunk of code and telling what it does or fixing syntax errors and one short 25 line program that I have to write on paper. Can someone give me any pointers as to very basic syntax differences between the two. Like how to write a basic "hello world" program in java/what code to throw in at the beginning of a program. Any basic help would be appreciated. Thanks.
 
Syntax/declarations is very much like c++, it certainly isn't any harder. You don't have to deal with memory management (a huge plus). I would recommend searching for some source code to simple programs and just looking through it. (careful of capitalizations)

String hello = "Hello World!";
System.out.println(hello);

or

System.out.println( "Hello World" );

Boom, there's your hello world.

Look through the Java APIs as well. Here.
 
Link to the intro to Java course at UC Davis. Most of the programs in the notes are fairly simple.

Anyway, stuff to take note of:
  • Syntax of declaration and instantiation of classes
  • Every non-primitive (i.e. int, bool, float, etc.) variable is a reference
  • Declaration of main() method
  • true and false do not equal 1 and 0 (doing true == 1 will give a compile error)
  • Syntax of public/private
 
Reading java code should be no problem However, if the ask you to write java code or questions along the line of "What do you import to ..." (aka language specific questions) then you will flunk.
 
If it's just System.out types of stuff, there is no issue, but otherwise there is a rather large object oriented API ( http://java.sun.com/j2se/1.4.1/docs/api/ ) that has nothing to do with C++, and if you do anything but using stdout, you have to at least understand some part of it. Even if some of the concepts might be similar, all the names are different (at least that different).

I would think going from Java to C++ would be a bit easier than the other way around 🙂
 
Back
Top