You are here:

Object Oriented Programming/Object Design specifying interfaces

Advertisement


Question
Consider the List interface in the java.util package for ordered collections of objects. Write preconditions and post conditions in OCL for the following operations:

int size() returns the number of elements in the list.

void add(Object e) adds an object at the end of the list.

void remove(Object e) removes an object from the end of the list.

boolean contains(Object e) returns true if the object is contained in the list.

Object get(int idx) returns the object located at index idx, 0 being the index of the first object in the list.

Answer
Dear Jeff,

Here is 2 useful resources regarding Java pre and post conditions.

http://www.cs.clarku.edu/~lhan/courses/cs121/frames_files/slides/PreAndPostCondi
http://docs.oracle.com/javase/1.4.2/docs/guide/lang/assert.html

Regards,
Anjana  

Object Oriented Programming

All Answers


Ask Experts

Volunteer


Anjana Silva

Expertise

I can contribute my knowledge on, how to effectively apply Object Oriented principles/techniques in your programming, various tools to draw Object Oriented diagrams, conversion between Code to specific Diagram vice verse. I can answer Object Orientation on both Java & PHP too.

Experience

I'm in the field of Object Oriented Programming for more than 3 years. So I know the big picture & advantage of using Object Oriented principles. I always use effective OO principles in my programming.

Organizations
1) e-Innoving IT Solutions - Owner/Developer
2) OpenArc Business Process Outsourcing - PHP Web Developer
3) Stan Bond (SA) PTY LTD - Web Application Developer


Publications

Few sites that I have developed.

1) http://www.legendmaldives.com
2) http://e-innoving.com/index.php/portfolio
3) http://www.vacationmaldives.com
4) http://www.stanbondsa.com.au
5) http://www.adelaidequalityblinds.com.au/
6) http://www.sybilwettasinghe.com
7) http://www.novels.lk
8) http://www.tapiis.com/demo (Treatment and Patient Information Improving System - my undergraduate research project)


Education/Credentials
Bachelor in Information Technology (UCSC)
Sun Certified Java Professional (SCJP)
Diploma in Advanced Web Techniques using Dreamweaver.


Awards and Honors
2nd Class Upper Award for my Bachelors Degree with an average GPA of 3.48

©2016 About.com. All rights reserved.