views:

121

answers:

7

I've been offered to be dispensed of classes in computer science in college, as the teacher noticed I obviously knew the introduction to coding. I'm extremely fluent in C# and with most programming concepts, so the exam shouldn't be so hard. I can also code in other languages such as C++, C, Lua, PHP, VB, etc.

I'm not caring about passing or not, my point is rather that this exam will be my only grade for the term. Therefore I'd like to get it right.

Let's assume I have ~2 weeks to prepare, I'd like to know where to start from. I obviously don't need to learn any concept (i.e. what is a variable, how to use classes, what is inheritance, etc.), since these are the same in most languages (or in that case, C# and Java).

I'd assume I have to get familiar with the slight syntax changes (string -> String, bool -> boolean) and system differences (i.e. Scanner for input, imports vs usings).

I've found the following page for most syntax changes:

http://it.toolbox.com/blogs/codesharp/java-for-c-developers-21248

From what I know, the test will variables and values, basic operators, logical structures (i.e. if/else, for, while), functions and structs. As far as I can remember, classes aren't seen this term.

I was interested in knowing what tips the S/O community could give me. Thanks in advance!

+1  A: 

Code in Java? Sounds easy, but it is, basically try doing a few "basic" things in java, IE make a linked list, some data structures.

Nicholas
+4  A: 

Well, first it really depends on the difficulty of your exam. You could have an exam on general POO in java or on more specific points, like generics, Collections, Threads.

And a thing you need to see, it the way the inheritance works in java. Methods inheritance isn't really working the same way.


Resources :

Colin Hebert
It's meant to be your first coding exam ever, so I assume generics, collections and threads are completely out of consideration. However, if you have some links regarding the difference between C# and Java for these concepts, I'd be glad to read them out of curiosity.Could you elaborate on different inheritance? I'll Google it, but still. :)
Lazlo
See the resources section :)
Colin Hebert
+1, good resource
aib
Great resource, thanks.
Lazlo
+2  A: 

This is just one of many examples, yet one of the biggest for me was creating getters/setters in Java compared to C#. C# has very nice shortcuts which you are probably use to.

Public string ExampleString { get; set; }

With Java you have to create methods instead.

private string _exampleString;

public string getExampleString()
{
    return _exampleString;
}

public void setExampleString(string exampleString)
{
    _exampleString = exampleString;
}

This is fundamentally the same way C# handles it, but you do not have the shortcut in Java. Ultimately to learn and get use to the differences your going to have to bite the bullet and write quite a few test programs. Especially if you need to know/understand Java UI, such as swing. Which I had to write my final project in swing when I took Java in school.

jsmith
Properties are the biggest thing I miss from C#. Especially when trying to write the Observer pattern for 49 events and listeners.
TheLQ
A: 

Try to code in Java, create something simple that you have already created in C# and than come to SO if you have any questions or queries and learn from the answers. I would suggest practicing would be of great help.

Rachel
A: 

To get the feeling of programming in the language I would suggest Project Euler, which requires you to write solutions to smallish programming problems.

The best way to learn is to write programs, and you need to practice a lot to prepare.

Thorbjørn Ravn Andersen
A: 

If you are allowed to use eclipse or netbeans as part of the evaluation then the most important thing you could do is get used to using those tools. Either of those could have you coding productively in Java within the hour because they will advise you on syntax issues and give you lists of choices so you don't have to look things up so often.

For instance, what is the method to grab a sub-chunk of a string. If you have an object of class "String" and hit strObject.(ctrl-space) it will give you a list of all the methods on string along with the parameter numbers and types. Oh and it will give you all the docs for this method as well.

If not, I'd get used to the JDK description on the Java website, you'll be using it more than Java syntax itself.

As for the Syntax, Java is pretty straight-forward. If you are coding in a GUI it will probably just fix your syntax for you.

If it's an in-class written (non-code) test, you may have to get used to some little differences like public/protected/private/package indications (package is the trickiest).

Bill K
A: 

Code some stuff, use Eclipse.

NB: Generics are hell in Java. Using a library that is "generified" correctly is simple, but coding generic classes and methods are often rather intense.

stolsvik
IDE recommendations are biased. I want to point out [NetBeans](http://netbeans.org/) (my favorite) and [IDEA](http://www.jetbrains.com/idea/). We have tastes, so just try them all (most are portable) and see which one you like
TheLQ