I need all these questions answered in the next hour and i will award more point
ID: 3557099 • Letter: I
Question
I need all these questions answered in the next hour and i will award more points if youd like as many as i can. I NEED THIS DONE ASAP PLEASE HELP!!!! THANK YOU!!!
Write the Java statement(s) to define and initialize each of the 200 elements of a one dimensional integer array to 20. Show how the array is defined. You must use a loop to accomplish this task.
Write the class definition header for a class called computer that inherits a class named Testing. (ONE line ONLY)
Assume that you have been given a method named q6 belonging to a class named class1 that prints the numbers 1 through 50.
Write the program segment to create an object named object1 from class1 and invoke this method 4000 times using any looping method.
Write the statement to create a JButton object named okButton with the label OK. Also, show how you would change the lable of the button to Cancel. Show how you would place the okButton object created in the previous question on a panel.
Write a program segment to assign the values 1 to 100 with steps of 1 to an array and then display the numbers stored in the array in reverse (100 down to 1) on the screen.
Assume that you have an object named course and that the object has access to a method named getCredits that returns the number of credits. Write the statement(s) to print the number of credits.
The following can be done in one class. Write a method to ask the user for a password. Give the user three chances to get the correct password (assume JAVA is the correct password). Display the message welcome if the user gets the correct password. If the correct password is not entered after 3 tries, display the message failed. Show how you would invoke this method. I do not need documentation. Assume a Scanner object named K has already been defined.
Explanation / Answer
Write the Java statement(s) to define and initialize each of the 200 elements of a one dimensional integer array to 20. Show how the array is defined. You must use a loop to accomplish this task.
int[] array = new int[200];
for(int i=0; i<200; ++i) {
array[i] = 20;
}
//-----------------------------------------------------------------------------------------------------------------------------
Write the class definition header for a class called computer that inherits a class named Testing. (ONE line ONLY)
public class computer extends Testing
//-----------------------------------------------------------------------------------------------------------------------------
Assume that you have been given a method named q6 belonging to a class named class1 that prints the numbers 1 through 50. Write the program segment to create an object named object1 from class1 and invoke this method 4000 times using any looping method.
class1 object1 = new class1();
for(int i=0; i<4000; ++i) {
object1.q6();
}
//-----------------------------------------------------------------------------------------------------------------------------
Write the statement to create a JButton object named okButton with the label OK. Also, show how you would change the lable of the button to Cancel. Show how you would place the okButton object created in the previous question on a panel.
public class JPanel extends javax.swing.JPanel {
public JPanel() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
okButton = new javax.swing.JButton();
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(39, 39, 39)
.addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(38, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(46, Short.MAX_VALUE))
);
}
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private javax.swing.JButton okButton;
}
//-----------------------------------------------------------------------------------------------------------------------------
//--------- To change label to 'cancel', modify :
//--------- okButton.setText("OK"); to okButton.setText("Cancel");
//-----------------------------------------------------------------------------------------------------------------------------
Write a program segment to assign the values 1 to 100 with steps of 1 to an array and then display the numbers stored in the array in reverse (100 down to 1) on the screen.
int[] array = new int[100];
for(int i = 0; i < 100; ++i) {
array[i] = i + 1;
}
for(int i = 99; i >= 0; --i) {
System.out.println(array[i]);
}
//-----------------------------------------------------------------------------------------------------------------------------
Assume that you have an object named course and that the object has access to a method named getCredits that returns the number of credits. Write the statement(s) to print the number of credits.
System.out.println("No. of credits for the course = " + course.getCredits() );
//-----------------------------------------------------------------------------------------------------------------------------
The following can be done in one class. Write a method to ask the user for a password. Give the user three chances to get the correct password (assume JAVA is the correct password). Display the message
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.