Tutorial 1, CPSC 331, Winter 2017

home page -  news -  syllabus -  schedule -  assignments -  tutorials -  java -  references -  Mike Jacobson


Tutorial 1 -  Tutorial 2 -  Tutorial 3 -  Tutorial 4 -  Tutorial 5 -  Tutorial 6 -  Tutorial 7 -  Tutorial 8 -  Tutorial 9 -  Tutorial 10 -  Tutorial 11 -  Tutorial 12 -  Tutorial 13 -  Tutorial 14 -  Tutorial 15 -  Tutorial 16 -  Tutorial 17 -  Tutorial 18 -  Tutorial 19 -  Tutorial 20 -  Tutorial 21 -  Tutorial 22 -  Tutorial 23 -  Tutorial 24

 Java Review

About This Exercise

This exercise can be used to help students get reaquainted with Java.

Students who are not familiar with Java should read through the following and make sure to attend the first tutorial, on January 18 and 19. Some or (if time permits) all of the questions given below will be discussed during this tutorial.

Students who are already familiar with Java will probably not find this tutorial to be of interest. However, it is nevertheless a good idea to at least read through the questions to make sure you remember the answers. If not, you should probably review your previous course materials on Java!

Expected Background and Preparation

As noted above, it is expected that students have some experience (probably by successful completion of one or more courses) with programming using Java, including some experience with object-oriented programming.

The first self-study exercise asked you to complete quite a bit of reading. It referenced an extensive set of online Java tutorials. You should be able to answer the questions that appear below after completing this reading and working through some (or all) of these tutorials.

Other tutorials, including tutorials that are designed specifically for C++ programmers, are also available and might be helpful as you consider the questions that follow.

Questions

  1. How are the source files for a Java program organized? What is a class?

  2. Where should the main method for a Java program be located in the source for this program?

  3. What is a package?

  4. What is an import statement used for?

  5. How can you prompt for input, receive input, and print output within the terminal (or console) from which you are running a Java program?

  6. How can you use separate dialog and message windows to prompt for and receive input, and display output, instead?

  7. How is storage space for objects allocated? In particular, how (and why) is this sometimes different than objects in C++ programs?

  8. How is storage space (for objects that are no longer referenced) reclaimed in Java? How is this different than is the case for C++ programs?

  9. Suppose you have defined an integer array A of length 10 in a Java program.

    1. How are the array entries indexed?

    2. What happens if you try to access the nonexistent entry A[11]? How is this different from what happens if you try to do the same thing in a C++ program?

Help Us To Improve This Course

Please send email to the course instructor if you are a C++ programmer who is learning Java in order to complete this course, if you notice something about Java, in the first few weeks of the course, that is not covered above and might also have been discussed during this first tutorial.

That said, please note that object-oriented programming concepts (such as inheritance or polymorphism) are deliberately not being covered at this point. It is hoped that these concepts will be introduced later on, as needed, so that you are not quite so overwhelmed at the beginning of the course.


Last updated:
http://www.cpsc.ucalgary.ca/~jacobs/Courses/cpsc331/W17/tutorials/tutorial1.html