Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# High level language, interfaces and structured programming logic

Greenhorn
Posts: 18
Here is a list of questions i'll appreciate explicit answers given

(1) How were higher level versions of programming languages designed from their low level representations?
How were low level representations of computer languages like machine and assembly languages abstracted to
a higher level language like java?

(2) What could be the most compelling reason(s) to create an interface for use in my program design? For most things i do
in my program design now i see that design of classes (abstract & concrete) can help me achieve the results directly.

(3) There're some lines of code i want explained. I just want to be clarified on the logic being depicted. These are few lines of
code from a section of a program fashioned to check for leap year. The program is out to explore Date.

//utility method confirm proper day value
//based on month and year

private int checkDay (int testDay)
{

" " "

if(month == 2 && testDay == 29 && (year % 400 = 0 II (year % 4 == 0 && year % 100 != 0)))

return testDay;

Where i'm not clear is the year variable in association with the modulus operator and the number 400, 4 and 100 involved.
what are the significance of these numbers in checking for leap year? i have no problem with the logical operator && joining
the first two expressions in the 'if' keyword. I'll appreciate a clear explanation.

Matthew Brown
Bartender
Posts: 4568
9
Olakunle Oladipo Oni wrote: Where i'm not clear is the year variable in association with the modulus operator and the number 400, 4 and 100 involved.
what are the significance of these numbers in checking for leap year?

Do you know what the logic for working out a leap year is?
- It's a leap year if the year is divisible by 4
- unless it's divisible by 100, in which case it isn't
- unless it's divisible by 400, in which case it is
(It's all to do with a year not being exactly 365 days long...or even 365.25)

Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15568
46
About your first question: Maybe the page History of programming languages on Wikipedia will give you some answers on this.

Olakunle Oladipo Oni wrote:if(month == 2 && testDay == 29 && (year % 400 = 0 II (year % 4 == 0 && year % 100 != 0)))

I see two errors in this line of code. The expression year % 400 = 0 is wrong; it should have been year % 400 == 0. A single = is used for assignment, and == for comparisons. Also, II (two capital letters i) will not work. Probably you meant || (two pipe symbols), which is the logical or operator.

If you have multiple, separate questions, please ask them in separate topics - it can become confusing if there are multiple discussions going on in one topic.