The Artima Developer Community
Sponsored Link

Java Answers Forum
memmory map

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
asad khan

Posts: 3
Nickname: asadkhan
Registered: Oct, 2007

memmory map Posted: Jan 11, 2008 8:34 AM
Reply to this message Reply
Advertisement
Can any body tell me how can we understand what will happen if we run following code, I just want to understand memmory maping


-----------------------------------------------------------
import java.io.*;
public class Student
{
String student1;
int scoreIn1;
int scoreIn2,grade;
float average;
int a=0;
public Student(String nameStudent)
{
student1=nameStudent;
}
void printName()
{
System.out.println("student1:" +student1);
}
int inputGrades()throws IOException
{
for(int x=0;x<2;x++)
{
do
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
System.out.print("marks=");
String inputLine=b.readLine();
grade=Integer.parseInt(inputLine);
if(grade<0 ||grade>100)
System.out.println("marks must be between 1 to 100");

if(a==0 && (grade>0 && grade<100))
{
scoreIn1=grade;
a++;
}
else
scoreIn2=grade;

}while(grade<0 || grade>101);
}
return(grade);
}
float getAverage()
{
average =(float)(scoreIn1+scoreIn2)/2;
System.out.println("The average for" + student1 + "is: " +average);
return average;
}
}
class Grades
{
public static void main(String []arg)throws IOException
{
Student std1=new Student("Asad");
std1.printName();
std1.inputGrades();
std1.getAverage();
Student std2=new Student("Saad");
std2.printName();
std2.inputGrades();
std2.getAverage();
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
char a=(char)b.read();
}
}

Topic: memmory map Previous Topic   Next Topic Topic: Accesing Image inside a jar file

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use