Vocabulary: Identify the vocabulary word for each definition below. Try It/Solve
ID: 3857577 • Letter: V
Question
Vocabulary:
Identify the vocabulary word for each definition below.
Try It/Solve It:
1. Take the following java code and using Eclipse place it into a package named greeting:
public class MyName {
private String name = "Jane";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void sayHello() {
System.out.println("Hi " + this.name);
}
}
2. Create a new package called converse in the same project and then create a class called Hello. You need to use
the sayHello method from your MyName class.
a) What do you need to include in your java program to get this to work?
b) Show your completed code.
3. You want to be change the name and then display the new name from within the Hello class.
a) How could you call the setName in a program before displaying the new name (Bob) to screen without using an
import statement for the package?
b) Show your completed code.
4. Using the following example create a runnable JAR file using Eclipse.
Example
1. In Eclipse create a new Java Project named dice.
2. In this project create a package also named dice.
3. In this package create a class named Random.
4. Add the following code to the Random class:
package dice;
import javax.swing.JOptionPane;
public class Random {
public static void main(String[] args) {
int rollOfDice;
String output;
// generate a random number between 1 and 6 inclusive
rollOfDice = (int) (Math.random() * 6) + 1;
//create a String message for the output window
output = "You rolled a " + rollOfDice;
// print message using a window
JOptionPane.showMessageDialog(null, output, "Random Number Demo",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}//end method main
}//end class Random
Now create a runnable JAR file and test that it runs outside the IDE!
the program independent of an IDE.-----------------? 2)Files that describes how your application/applet should be launched.---------------? 3)Files can be displayed in a web browser as web pages.------------? 4)A java system with a client and a server.-------------? 5)A java system with a client, a server, and a database.-----------? 6)A collection of java classes organized together.-------------? 7)A java version of zip files.---------?
Explanation / Answer
4)A java system with a client and a server. - client/server application
7)A java version of zip files. - jar (java Archive)
MyName.java
package greeting;
public class MyName {
private String name = "Jane";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void sayHello() {
System.out.println("Hi " + this.name);
}
}
MyName.java
package converse;
//import statement for the package
import greeting.MyName;
public class Hello extends MyName{
//you need to extends MyName in class Hello to use
// the sayHello method from your MyName class
@Override
public void sayHello() {
super.setName("Bob"); //Setting new name
super.sayHello();
}
}
To create a JAR file-> Please folow the below steps
1. In Eclipse create a new Java Project named dice.
2. In this project create a package also named dice.
3. In this package create a class named Random.
4. Add g code to the Random class and Save
5. Right click on project dice and click Export
6.Select Jar File option and click Next
7.Give Destination and Finish
1)The process of getting your program ready and available for any user to runthe program independent of an IDE. - Compilation 2)Files that describes how your application/applet should be launched. - Launch configuration 3)Files can be displayed in a web browser as web pages.- True
4)A java system with a client and a server. - client/server application
5)A java system with a client, a server, and a database - client/server database 6)A collection of java classes organized together. - package7)A java version of zip files. - jar (java Archive)
MyName.java
package greeting;
public class MyName {
private String name = "Jane";
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void sayHello() {
System.out.println("Hi " + this.name);
}
}
MyName.java
package converse;
//import statement for the package
import greeting.MyName;
public class Hello extends MyName{
//you need to extends MyName in class Hello to use
// the sayHello method from your MyName class
@Override
public void sayHello() {
super.setName("Bob"); //Setting new name
super.sayHello();
}
}
To create a JAR file-> Please folow the below steps
1. In Eclipse create a new Java Project named dice.
2. In this project create a package also named dice.
3. In this package create a class named Random.
4. Add g code to the Random class and Save
5. Right click on project dice and click Export
6.Select Jar File option and click Next
7.Give Destination and Finish
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.