Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Class example from book on Object locations -Comping objects (addresses) public class DemoA { public static void main(String[] args) { double average; StudentA std1,

image text in transcribed // Class example from book on Object locations -Comping objects (addresses) public class DemoA { public static void main(String[] args) { double average; StudentA std1, std2, std3; //Declare objects of type Class // Build student objects using "default" constructor std1= new StudentA(); //Create new object belonging to Class // stores the reference (pointer) to that object in , System.out.println("std1 memory pointer in hex " + std1); std2= new StudentA(); //create second object belonging to Class // stores reference to that object in which is different for System.out.println("std2 memory address in hex " + std2); std3=null; System.out.println("std3 memory address in hex " + std3+" "); // outputs the Hex the point of std1 std3= std1; //copy the "reference" value (memory address) of std1 into std3 not eh Object itself System.out.println("std3 memory address in hex " + std3); // outputs the Hex the point of std1 // // add data in to object and std1.name="Joe"; std2.name="Bill"; System.out.println("std1 name " + std1.name); // Joe System.out.println("std2 name " + std2.name); // Bill System.out.println("std3 name " + std3.name); // Joe again // Arrays in Student class System.out.println("array in class student std1 "+std1.testArray ); System.out.println("array in class student std2 "+std2.testArray ); System.out.println("array in class student std3 "+std3.testArray ); average= std1.getAverage(); // "call" method in class Student System.out.println(std1.name +" average " + average); }// End Main }//End Class

Might someone tell me why those error occurred and how to fix them ?

it say: student A cannot be resolved to a type

ava Java StudentB/src/ DemoAjava Eclipse File Edit Source Refactor Navigate Search Project Run Window Help Package Explorer 3 student A 2 Class example from book on object locations -Compina objects (addresses) src default package) public class DemoA public static void main (String args) Demo java double average D a JRE System Library JavaSE-1.8] Student A atdl, atd2, atd3 Declare objects of type Class which is different 13 System, out.println atd2 memory addreas in hex atd2 14 atd3-nall 15 System, out.println atd3 memory addreaa in hex at d3+" outputs the 16 atd3 atd1 copy the reference value memory addreaa of atdl into atda 17 System, out.println atd3 memory addreaa in hex atd3 output the Hex t 18 19 add data in to object Katdl and Katd2 atd1 Joe atd2 name Bill System. out println atd1 name atdl .name) Joe System, out println atd2 name atd2 name B1ll System, out printin atd3 name atd3.name) Joe again avadoc Declaration Problem rs, 0 warning s, 0 o hers. Path Location Type Desc Resource ption a Errors items0 StudentA cannot be resolved to a type DemoAjava /StudentB/src line 6 Java Problem StudentA cannot be resolved to a type Demo Ajava studentB/src line 8 Java problem n StudentA cannot be resolved to a typ Demo Ajava student B/src line 11 Java Problem Quick Access EN Task List Find Activate... Outline P., DemoA main(Stringll void

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Discuss the advantages and disadvantages of online focus groups.

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago