Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools

Assignment 1: Java Knowledge

Release date: Thursday, 07.04.11 - Due date: Sunday, 17.04.11, 23:59

Task 01: Concept Jungle

3 points

Explain the following terms in 1-3 sentences for each:

  • interface
  • generics
  • inheritance
  • dynamic binding
  • overloading
  • garbage collection
  • bytecode

Task 02: Java Multiple Choice

0-3,5 points: +0.5 per correct answer, -0,5 per incorrect
Question Yes No
All necessary classes must be available as source code for execution.
Values of variables declared as “static” cannot be altered during runtime.
The return type of overloaded methods has to be equal.
Essential for a method signature are only it's name and the ordered list of parameter types.
Interface may only declare public methods.
“Object” and “class” can be used as synonyms.
If o1 and o2 are both objects, then the following expressions are equivalent: o1 == o2 and o1.equals(o2).

Task 03: Programming Warmup

4 points

Implement a program that can calculate the following series. It should be possible to input an index of the series and the program should calculate the result for this index.

<code > n(0)= 1 n(1)= 0 n(2)= 2 n(3)=-1 n(4)= 3 n(5)=-2 n(6)= 4 .. </Code>

Task 04: Overloading vs overriding

3 points

Explain the difference between overloading, overriding and shadowing. If necessary, provide a snippet illustrating your explanation.

Task 05: Static vs dynamic binding

3 points

Given the following Java code:

class C1 {
  static int s=1;
  void f1(){
  void f2(){

class C2 extends C1 {
  static int s=2;
  void f1(){
  void f3(){

public class Test {
  static public void main ( String[ ] args ) {
   C1 a=new C2();
   C2 b=new C2();
    Insert code here

Provide the output of the program above, with the below lines inserted at the “Insert code here” line. Compile and runtime-errors are also possible explanations.

  1. ((C2) a).f1();
  2. ((C1) b).f1();
  3. System.out.println(a.s);
  4. b.f1();
  5. b.f2();
  6. b.f3();
  7. C1 c = new C1(); c.f3()
  8. C1 c = new C1(); ((C2) c).f1();

(optional)Task: More Java Exercises

0 points

The following task is optional and is meant for self-evaluation only, if you are curious to assess your own skills. This task is therefore not corrected or graded. The warmup is normally used as a programming warmup for a programming lab in our department.

You can find it here. Very fast students were able to solve this warmup in two hours. If it takes you up to two days, it would still be OK.

teaching/lectures/oosc/2011/assignment_1.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024