Missing Braces In Java, braces are used to group statements and declarations together. Each opening brace should be acco
Posted: Sun Jul 03, 2022 12:01 pm
Missing Braces In Java, braces are used to group statements and declarations together. Each opening brace should be accompanied with a closing brace otherwise compilation of the code would result in a failure. Given a piece of code in Java, determine whether the code will give a compilation error due to missing brace(s) or not. Note: You should not consider any other errors except the ones due to missing braces. Input Specification: input 1: a string containing Java code Output Specification Return "error in case there will be a compilation error due to missing bracels) Retu correct in case there is no such error. Example 1 input1 public static void cain (String[] args) { if(true) [ System.out.print("hello world!"); 7 Output error Explanation: There is a compilation error in the given code as the closing brace for the if statement is missing. Example 2 input1: for (int counter = 0; counter <10; counter++) { System.out.print(" Value of counter 25: + counter); Output: correct Explanation: There are no compilation errors due to the braces in the given code Mert! Online Aare ment 2021 2011 ZAN Recorded Session
JAVAS ANM†U UNØ GO : ª ª 175 4 6 import java.io.*; import java.util.*: 5 class UserMainCode 13 // Read only region start { Compiler: Java - 1.8 public string checkBraces(String input1) { } // Read only region end // Write code here... throw new UnsupportedoperationException("checkBraces (String input1)"); I