Knowee
Questions
Features
Study Tools

Determine the output:public class A { public static void main(String argv[]){ int ary[]=new int[]{1,2,3}; System.out.println(ary[1]); }}Select one:a.2b.1c.Compilation Error:incorrect syntax

Question

Determine the output:public class A { public static void main(String argv[]){ int ary[]=new int[]{1,2,3}; System.out.println(ary[1]); }}Select one:a.2b.1c.Compilation Error:incorrect syntax

🧐 Not the exact question you are looking for?Go ask a question

Solution

a.2

Similar Questions

Determine the output:class Evaluate {                 public static void main(String args[])                 {                                 int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};                                 int n = 6;                                 n = arr[arr[n] / 2];                                 System.out.println(arr[n] / 2);                 } }Select one:a.1b.6c.3d.0

elect the correct answerPredict the output ?class Test {  public static void main(String args[]) {   int arr[] = new int[2];     System.out.println(arr[0]);   System.out.println(arr[1]);  }}OptionsCompiler Errorgarbage valuegarbage value00Exception

Determine the output:public class Test{        public static void main(String[] args)                {                int[] x = new int[3];                System.out.println("x[0] is " + x[0]);        }}Select one:a.The program has a runtime error because the array elements are not initialized.b.The program has a runtime error because the array element x[0] is not defined.c.The program has a compile error because the size of the array wasn't specified when declaring the array.d.The program runs fine and displays x[0] is 0.

Analyze the following code carefully. Please select the one that applies.public class Test {  public static void main(String[] args) {    A a = new A();    a.print();  }}class A {  String s;  A(String s) {    this.s = s;  }void print() {    System.out.println(s);  }}Group of answer choicesThe program would compile and run if you change A a = new A() to A a = new A(5).The program has a compile error because class A is not a public class.The program has a compile error because class A does not have a default constructor.The program compiles and runs fine and prints nothing.

Consider the below code snippet  and determine the output.class Student{ private int studentId; private float average;}class Test{ public static void main(String a[]) { Student s=new Student(); s.studentId=123; System.out.println(s.studentId); }}Select one:a.Any valueb.0c.Compile time errord.1

1/3

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.