Purchase Solution

Write a user-defined class called Person.

Not what you're looking for?

Ask Custom Question

1. What is the difference between a Java compiler and a Java interpreter?

2. Write a user-defined class called Person. This class should have private instance variables defined as:

private int age;private String firstName;private String lastName;
In addition, the class should have a constructor defined as:

public Person(String _firstName, String _lastName, int _age)
that assigns values to the private instance variables. The class should also include the following public methods:

public void printName() - prints the person's namepublic void printAge() - prints the person's agepublic void printAgeGroup() - prints the person's age group (i.e. 20's. 30's, etc.)
Only include this last method if it is necessary to include logic in the assignment.

Write a second class with the method, "public static void main(String args[])". At least two objects based on the Person class should be created in the "main" method. The name, age, and age group should be displayed for each object.

3. Pick a problematic situation that you think a Java program can solve or make easier. Explain the problem and then write the pseudo code for it.

Purchase this Solution

Solution Summary

What is the difference between a Java compiler and a Java interpreter?

Solution Preview

1. Java compiler is a program which translates Java language source code into the Java Virtual Machine (JVM) bytecodes. Java interpreter is a program which implements the JVM specification and actually executes the bytecodes (and thereby running your program).

2. See attached.

3. One area is the creation of threads. Thread application is a very important part of programming. However, other languages such as C++ is not very easy to create and manage threads. Compared to these languages, Java make creating and mangement of threads much easier. Here is a sample code:

public class SimpleThreads {

//Display a message, preceded by the name of the current thread
static void threadMessage(String message) {
String ...

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

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.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.