ExamCompetition Forum Question Papers Ask A Question Mock Test Learn & Earn Sign Up Login Menu

Computer science Practice Questions & Answers

23 vote

What is the value of a[1] after the following code is executed?int[] a = {0, 2, 4, 1, 3};for(int i = 0; i < a.length; i++)a[i] = a[(a[i] + 3) % a.length];

Asked on by Guest | Votes 23

What is the value of a[1] after the following code is executed?int[] a = {0, 2, 4, 1, 3};for(int i = 0; i < a.length; i++)a[i] = a[(a[i] + 3) % a.length];

A).  0

B).  1

C).  2

D).  3

E).  4

35 vote

What will be the output of the program?public class Test{ public static void main(String [] args){ String s1 = args[1]; String s2 = args[2]; String s3 = args[3]; String s4 = args[4]; System.out.print(" args[2] = " + s2); }}and the command-line invocation is C:Java> java Test 1 2 3 4

Asked on by Guest | Votes 35

What will be the output of the program?public class Test{ public static void main(String [] args){ String s1 = args[1]; String s2 = args[2]; String s3 = args[3]; String s4 = args[4]; System.out.print(" args[2] = " + s2); }}and the command-line invocation is C:Java> java Test 1 2 3 4

A).  args[2] = 2

B).  args[2] = 3

C).  args[2] = null

D).  An exception is thrown at runtime.

0 vote

Which will legally declare, construct, and initialize an array?

Asked on by Guest | Votes 0

Which will legally declare, construct, and initialize an array?

A).  int [] myList = {};

B).  int [] myList = (5, 8, 2);

C).  int myList [] [] = {4,9,7,0};

D).  int myList [] = {4, 3, 7};

26 vote

What would be the result of attempting to compile and run the following code?public class HelloWorld{ public static void main(String[] args){ double[] x = new double[]{1, 2, 3}; System.out.println("Value is " + x[1]); }}

Asked on by Guest | Votes 26

What would be the result of attempting to compile and run the following code?public class HelloWorld{ public static void main(String[] args){ double[] x = new double[]{1, 2, 3}; System.out.println("Value is " + x[1]); }}

A).  The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by {1, 2, 3}.

B).  The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[3]{1, 2, 3};

C).  The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[]{1.0, 2.0, 3.0};

D).  The program compiles and runs fine and the output

0 vote

Assume, you are the administrator of the TUNA domain. You need to allow Lisa from the BASS domain to administrate the TUNA domain while you are on vacation. A one-way trust relationship has been set up so that TUNA trusts BASS. Which group assignments would accomplish your needs?

Asked on by Guest | Votes 0

Assume, you are the administrator of the TUNA domain. You need to allow Lisa from the BASS domain to administrate the TUNA domain while you are on vacation. A one-way trust relationship has been set up so that TUNA trusts BASS. Which group assignments would accomplish your needs?

A).  Create a global group in the TUNA domain called Tuna-Admins that contains the BASSWLisa user account. Add the Tuna-Admins group to the local Administrators group in TUNA

B).  Create a local group in TUNA called Tuna-Admins that contains the BASSWLisa user account. Add the Tuna-Admins group to the global Domain Admins group in TUNA

C).  Create a global group in BASS called Gbl-Admins that contains the Lisa user account. Add the BASSGbl-Admins group to the local Administrators group in TUNA

D).  Create a local group in BASS called Loc-Admins that contains the Lisa user account. Create a global group in TUNA called Tuna-Admins that contains the BASSWLoc-Admins group. Add the Tuna-Admins group

E).  None of the above