Select the correct answerWhat will be the output of the following Java program? class Codetantra { public static void main(String[]args) { String[] elements = { "One", "two", "three" }; String first = (elements.length > 0) ? elements[0]: null; } }OptionsThe variable first is set to nullAn exception is thrown at run timeCompilation errorThe variable first is set to elements[0]
Question
Select the correct answerWhat will be the output of the following Java program? class Codetantra { public static void main(String[]args) { String[] elements = { "One", "two", "three" }; String first = (elements.length > 0) ? elements[0]: null; } }OptionsThe variable first is set to nullAn exception is thrown at run timeCompilation errorThe variable first is set to elements[0]
Solution
The variable first is set to elements[0]
Similar Questions
What is the output of this program?class Abc{public static void main(String[]args){String[] elements = { "for", "tea", "too" };String first = (elements.length > 0) ? elements[0]: null;}}Select one:Compilation errorAn exception is thrown at run timeThe variable first is set to elements[0].The variable first is set to null
Select the correct answerWhat will be the output of the following Java program, if we run as “java Codetantra 4 7 9”? class Codetantra { public static void main(String [] args) { String [][] argument = new String[2][2]; int a; argument[0] = args; a = argument[0].length; for (int b = 0; b < a; b++) System.out.print(" " + argument[0][b]); } }Options4 04 44 0 94 7 9
Select the correct answerWhat will be the output of the following Java code? class Codetantra { final public int output(int x, int y) { return 1; } } class Program extends Codetantra { public int output(int x, int y) { return 2; } } public class result { public static void main(String args[]) { Program object = new Program(); System.out.print("y is " + y.output(0, 1)); } }Optionsy is : 0y is : 1Compilation ErrorAn exception is thrown at runtime
Select the correct answerWhat will be the output of the following Java code? class Name { public static void main(String args[]) { try { int ct1 = 0; int ct2 = 5; int ct3 = ct1 / ct2; System.out.print("Hello"); } catch(Exception e) { System.out.print("Codetantra"); } } }OptionsCodetantraHelloHelloCodetantraCompilation Error
Select the correct answerWhat will be the output of the following Java program? class string_demo { public static void main(String args[]) { String obj = "I" + "like" + "CodeTantra"; System.out.println(obj); } }OptionsjavaCodeIIlikeCodeTantra
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.