aspose file tools*
The moose likes Beginning Java and the fly likes High level language, interfaces and structured programming logic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "High level language, interfaces and structured programming logic" Watch "High level language, interfaces and structured programming logic" New topic
Author

High level language, interfaces and structured programming logic

Olakunle Oladipo Oni
Greenhorn

Joined: Aug 28, 2008
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.

olakunle oladipo oni
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4392
    
    8

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

Joined: Aug 16, 2005
Posts: 14164
    
  19

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: High level language, interfaces and structured programming logic