Purchase Solution

Java - Lines of Code

Not what you're looking for?

Ask Custom Question

Explain the ten lines of code marked (1)..(10) after analyzing the code, running the program, and examining the output.Explanation each of the lines of code (1..10), that is, what the code does logically and what it does in the program.

Attachments
Purchase this Solution

Solution Summary

10 lines of code are analysed and explained and the output checked.

Solution Preview

The purpose of this code is to show that static fields are shared by all objects of the same class. Its output is

color is: red
claws are: 5
eyes are: 4
claws: 15
color: green
color: green
eyes: 7

Now I explain each line of the codes from 1 to 10.
(1) static int claws = 5;
This line is to define the static field claws. So monster.flaws = 5.

In the first line of the main method, we have
monster.display();
It will display the current static fields in monster class. So it outputs
color is: ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Networking Questions

This quiz consists of some basic networking questions.