SDA SE Wiki

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

User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
teaching:lectures:oosc:2011:assignment_1 [2011/04/04 16:12]
jan.nonnen
teaching:lectures:oosc:2011:assignment_1 [2018/05/09 01:59] (current)
Line 1: Line 1:
 +====== Assignment 1: Java Knowledge ======
 +
 +<​html><​font color=darkred></​html>​**Release date: Thursday, 07.04.11 - Due date: Sunday, 17.04.11, 23:​59**<​html></​font></​html>​
 +
 +===== 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:
 +<Code lang-java>​
 +class C1 {
 +  static int s=1;
 +  void f1(){
 +   ​System.out.println("​C1::​f1"​);​
 +  }
 +  void f2(){
 +   ​System.out.println("​C1::​f2"​);​
 +  }
 +}
 +
 +class C2 extends C1 {
 +  static int s=2;
 +  void f1(){
 +   ​System.out.println("​C2::​f1"​);​
 +  }
 +  void f3(){
 +   ​System.out.println("​C2::​f3"​);​
 +  }
 +}
 +
 +public class Test {
 +  static public void main ( String[ ] args ) {
 +   C1 a=new C2();
 +   C2 b=new C2();
 +    Insert code here
 +  }
 +}
 +</​Code>​
 +
 +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.
 +  - ((C2) a).f1();
 +  - ((C1) b).f1();
 +  - System.out.println(a.s);​
 +  - b.f1();
 +  - b.f2();
 +  - b.f3();
 +  - C1 c = new C1(); c.f3()
 +  - 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 [[http://​sewiki.iai.uni-bonn.de/​teaching/​labs/​xp/​2005a/​javawarmup|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. 
  

SEWiki, © 2019