Answer:
The program in Java is as follows:
public class SumThousand {
public static void main(String args[]) {
int sum=0;
for(int i =1;i<=1000;i++)
sum+=i;
System.out.println("Sum = " + sum);
}
}
Step-by-step explanation:
This initializes sum to 0
int sum=0;
This iterates from 1 to 1000
for(int i =1;i<=1000;i++)
This calculates the required sum
sum+=i;
This prints the calculated sum
System.out.println("Sum = " + sum);