1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anvisha [2.4K]
3 years ago
5

Identify and fix the 5 errors in the following code

Computers and Technology
1 answer:
oksian1 [2.3K]3 years ago
5 0

Answer:

Following error are present in the given code:

1. I in Import javax.swing.JOptionPane; is capital.

2. Spaces are there in class name Welcome to JAVA

3. Return type not mentioned for Main function.

4. Second argument (Welcome To Java) in function showMessageDialog() not enclosed within double quotes.

5. Main method and Class not enclosed within curly braces.

Explanation:

Following are fixes and explanation for above errors.

Error 1:

Since Java is case sensitive therefore I in import should be small. Correct statement is as follows:

import javax.swing.JOptionPane;

Error 2:

In Java identifiers cannot have spaces. Since Welcome to JAVA is an identifier thus it should not contain any spaces. Correct statement is as follows:

public class welcomeToJava{

Error 3:

In Java every method should have a return type. Main() method has  return type of void. Thus void keyword should be present after static. Correct statement is as follows:

public static void main(String[] args)

Error 4:

Second and third argument in method showDialog() should be  of string type. Thus they should be enclosed within double quotes. Correct statement is as follows:

JOptionPane.showMessageDialog(null,"Welcome To Java","Display this Message",JOptionPane.INFORMATION_MESSAGE);

Error 5:

All methods and class should be enclosed within an opening and closing curly braces.

Thus complete correct code will be as follows:

import javax.swing.JOptionPane;

public class welcomeToJava{

public static void main(String[] args) {

// Display welcome to java in a dialogue box  

JOptionPane.showMessageDialog(null,"Welcome To Java","Display this Message",JOptionPane.INFORMATION_MESSAGE);

}

}

You might be interested in
A network ____ usually contains a computer, networked peripheral, or network device.
Archy [21]
Card
......... ......... ........
8 0
4 years ago
ACTIVITY NO. 5 (DAY 5) FACT OR BLUFF. Write Fact if the statement is correct and write Bluff if it is incorrect.
KengaRu [80]

All of the above are Facts.

preventive maintenance does indeed help with the lifespan etc.

If you are feeling tired or fatigued when operating machinery, stop and rest for fear of mistake. So , two is also correct

4if you dress inappropriately it may cause danger from getting caught in machinery or catching a flame depending on the worksite. so four is correct. Newer models are most likely more updated and have different operations then the last machine. so yes read the manual before using it. so yet again 5 is also correct.

hopefully this helped

3 0
3 years ago
Question 12 (1 point)
QveST [7]

Answer:

margins

Explanation:

the definition margins are the edges

8 0
3 years ago
In this exercise you will debug the code which has been provided in the starter file. The code is intended to do the following:
abruzzese [7]

Answer:

The corrected code is as follows:

import java.util.Scanner;

public class U2_L4_Activity_Two{

public static void main(String[] args){

Scanner scan = new Scanner(System.in);

String str1 = scan.nextLine();

String str2 = str1;

str1 = str1.toUpperCase();

System.out.println(str1);

System.out.println(str2);

}

}

Explanation:

This corrects the scanner object

Scanner scan = new Scanner(System.in);

This line is correct

String str1 = scan.nextLine();

This copies str1 to str2

String str2 = str1;

This converts str1 to upper case

str1 = str1.toUpperCase();

This prints str1

System.out.println(str1);

This prints str2

System.out.println(str2);

8 0
3 years ago
You have several reference computers. The computers are configured to always start from a local hard disk drive. You plan to cap
aivan3 [116]

Answer:

it is C.

Explanation:

3 0
4 years ago
Other questions:
  • Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l
    6·1 answer
  • What error, if any, is in the following code?
    11·1 answer
  • Which type of system would be more reliable for keeping a plane traveling at constant speed – an automatically controlled feedba
    11·1 answer
  • Which of the following can be considered beta testing? A programmer at Linus Systems checks the integration of multiple modules
    14·1 answer
  • What are the pros and cons of the internet’s ability to access information
    8·2 answers
  • Students who respond promptly to e-mails are following which netiquette rule?
    13·2 answers
  • Eight what makes one character
    14·1 answer
  • Xavier buys a new laptop for $540. He makes a down payment $75 and pays the rest in 6 equal monthly payments, p. What equation r
    7·1 answer
  • Is it possible build a real time machine?
    7·2 answers
  • Binary subtraction<br> Subtract (111) from (1000)
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!