1) Provide a reason why an instance data would be declared static. 2) Write a method that takes an array of Strings as a parameter and the number of elements currently stored in the array, and returns...

1 answer below »

1) Provide a reason why an instance data would be declared static.


2) Write a method that takes an array of Strings as a parameter and the number of elements currently stored in the array, and returns a single String that is the concatenation of all Strings in the array.


3) Assume the class Student implements the Speaker interface from the textbook. Recall that this interface includes two abstract methods, speak( ) and announce(String str). A Student contains one instance data, String classRank. Write the Student class so that it implements Speaker as follows. The speak method will output "I am a newbie here" if the Student is a "Freshman", "I hate school" if the Student is either a "Sophomore" or a "Junior", or "I can not wait to graduate" if the student is a "Senior". The announce method will output "I am a Student, here is what I have to say" followed by the String parameter on a separate line. Finally, the classRank is initialized in the constructor. Only implement the constructor and the methods to implement the Speaker interface.


4) Write the init and paint methods of an Applet and the methods needed to implement MouseMotionListener so that the applet can draw a point on the applet for every mouse position as the mouse is being moved on the screen. Use a 2-D array of ints to represent the X and Y coordinates of the mouse as it is being moved. For instance, point[0][0] and point[0][1] represent the X and Y coordinates of the mouse at its first position. The paint method will need to be called every time the mouse is moved and all points redrawn on the applet. (L9).


5) The class Name consists of 4 instance data, String title, String first, String middle, String last. The class has a constructor that is passed all 4 String values and initializes the class appropriately, and has 4 methods, each returns one of the four instance data, called returnTitle( ), returnFirst( ), returnMiddle( ) and returnLast( ). Name[ ] addressBook = new Name[100]; is performed. Write a method that is passed 4 String parameters corresponding to a Name's title, first, middle, and last, and finds this Name in addressBook and returns the index of where this Name was found, or -1 if the Name was not found. Assume that addressBook stores n entries (n is an int). (L8)

Answered 1 days AfterFeb 06, 2021

Answer To: 1) Provide a reason why an instance data would be declared static. 2) Write a method that takes an...

Ayush answered on Feb 08 2021
151 Votes
Assignment 75453/Task 2/applet.policy
grant {
permission java.security.AllPermission;
};
Assignment 75453/Task 2/build.xml

Builds, tests, and runs the project Task 2.


Assignment 75453/Task 2/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Assignment 75453/Task 2/nbproject/build-impl.xml















































































































































































































Must set src.dir
Must set test.src.dir
Must set build.dir
Must set di
st.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar




































































































Must set javac.includes
































































































































No tests executed.























































































































































































































































Must set JVM to use for profiling in profiler.info.jvm
Must set profiler agent JVM arguments in profiler.info.jvmargs.agent





























































































































































































































Must select some files in the IDE or set javac.includes













































To run this application from the command line without Ant, try:

java -jar "${dist.jar.resolved}"










































Must select one file in the IDE or set run.class



Must select one file in the IDE or set run.class






















Must select one file in the IDE or set debug.class




Must select one file in the IDE or set debug.class




Must set fix.includes









This target only works when run from inside the NetBeans IDE.








Must select one file in the IDE or set profile.class
This target only works when run from inside the NetBeans IDE.








This target only works when run from inside the NetBeans IDE.












This target only works when run from inside the NetBeans IDE.



































Must select one file in the IDE or set run.class





Must select some files in the IDE or set test.includes




Must select one file in the IDE or set run.class




Must select one file in the IDE or set applet.url






































































Must select some files in the IDE or set javac.includes



















Some tests failed; see details above.








Must select some files in the IDE or set test.includes



Some tests failed; see details above.



Must select some files in the IDE or set test.class
Must select some method in the IDE or set test.method



Some tests failed; see details above.




Must select one file in the IDE or set test.class



Must select one file in the IDE or set test.class
Must select some method in the IDE or set test.method













Must select one file in the IDE or set applet.url








Must select one file in the IDE or set applet.url




















































Assignment 75453/Task 2/nbproject/genfiles.properties
build.xml.data.CRC32=10ab092a
build.xml.script.CRC32=2c2824a8
[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=10ab092a
nbproject/build-impl.xml.script.CRC32=cd43b5ff
nbproject/[email protected]
Assignment 75453/Task 2/nbproject/private/private.properties
compile.on.save=true
user.properties.file=C:\\Users\\LENOVO\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
Assignment 75453/Task 2/nbproject/private/private.xml


Assignment 75453/Task 2/nbproject/project.properties
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/Task_2.jar
dist.javadoc.dir=${dist.dir}/javadoc
excludes=
includes=**
jar.compress=false
javac.classpath=
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=-Djava.security.policy=applet.policy
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
Assignment 75453/Task 2/nbproject/project.xml

org.netbeans.modules.java.j2seproject


Task 2








Assignment 75453/Task 2/src/Main.java
Assignment 75453/Task 2/src/Main.java
//Program to implement method to concatenate strings
public class Main 
{
    public static void main(String[] args) 
    {
        Concatenate cat = new Concatenate();
        String[] fruits = {"Apple","Banana","Chickoo","Orange","Grapes"};
        String answer = cat.concatStr(fruits, fruits.length);
        System.err.println(answer);
    }
}
class Concatenate 
{
    String concatStr(String[] arg,int num_of_elem)
    {
        String str = null;
        for (int i=0; i        {
            if (i == 0) 
            {
                str = arg[i];
            }
            else
            {
                str += "\t" + arg[i];
            }
        }
        return str;
    }
}
Assignment 75453/Task 3/build/classes/.netbeans_automatic_build
Assignment 75453/Task 3/build/classes/.netbeans_update_resources
Assignment 75453/Task 3/build/classes/Main.class
public synchronized class Main {
public void Main();
public static void main(String[]);
}
Assignment 75453/Task 3/build/classes/Speaker.class
public abstract interface Speaker {
public abstract void speak();
public abstract void announce(String);
}
Assignment 75453/Task 3/build/classes/Student.class
public synchronized class Student implements Speaker {
String classRank;
public void Student(String);
public void speak();
public void announce(String);
}
Assignment 75453/Task 3/build.xml

Builds, tests, and runs the project Task 3.


Assignment 75453/Task 3/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Assignment 75453/Task 3/nbproject/build-impl.xml















































































































































































































Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar




































































































Must set javac.includes






















































































...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here