Question: Java 1) Write a complete program (imports, class, etc.) in a class named mypkg.ECounter that (when executed within NetBeans) will read its own source code
Java
1) Write a complete program (imports, class, etc.) in a class named mypkg.ECounter that (when executed within NetBeans) will read its own source code and print out a message telling how many of its lines contained the character 'e' at least once.
2) Every shape has a color and a position. Shape is an abstract class. Specify a method of the Shape class that will be given a bunch of Shapes and will tell how many of them have the same color as this Shape. Don't write the body.
3) Person is a class that has just two fields, anme and age. Assume it has public access methods getName and getAge and setName and setAge. Write a client method (i.e. a method that is not a member of Person) that is passed an array of Person and that returns an independent copy of the array.(Don't try to use clone.) Hint: the returned array must not refer to the same objects as the original array refers to. Don't forget tp include the specification comments.
4) Here is a class for you to complete. It represents a single clown, whose attributes are his name, his age, and the name of his circus. Add as little as possible, but provide and label (using a,b,c, and d) the following:
a) A constructor
b) An access method
c) Code that overloads a method or constructor
d) Code that overrides a method or constructor
Also, explain why your Clown class is or is not immutable:
public class Clown extends Object{
private String name,circus;
private int age;
5) Complete this method: This method is NOT a member of the Employee class. (The class Employee is the one we worked on in lab; each Employee has attributes name, age, and boss and has public methods getAge, getName, and getBoss. Its constructor throws BadEmployeeException when given bad data.)
/**pre: list contains objects, some of which are Employees, but may
contain other things also
post: returns true iff at least one Employee in list has "Doug" as her boss
throws an Exception if there are no Employees at all on the list
*/
static boolean hasDoug(ArrayList
4)5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
