Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java Programming


7. What are the values of x, y & z after executing the following? int x = 4; int y = 6; if (y <=x) x = 3 + y; y = x + y; z = x * y; A. x=4, y=6, z=10 B. x=4, y=6, z=24 C. x=7, y=13, z=91 D. x=7, y=10, z=70 E. None of the Above 8. Which is not a legal identifier? A. BiglongVariable B. Big#LongVariable C. $BiglongVariable D. _Big_longVariable E. Big33r4 9. What method will be used? printMe(5); A. public void printMe(int a){} B. private void printMe(int b){}//in a class outside the package (out of Project) C. public int printMe(int c, double a){} D. private double printMe(double c){} 10. How would you create an instance of the myClass? A. myClass m = new myClass(); B. MyClass m = new MyClass(); C. MyClass m = MyClass(); D. myClass m = MyClass(); 11. True(a) or False(b) int a and int A are two different variables 14. Which statements about the output of the following program are true? public class StringTest { public static void main(String args[]) { String s1 = new String(“YES”); String s2 = new String(“YES”); if ( s1 == s2 ) System.out.println(“equal”); System.out.println(“not Equal”); (a) compile error. (b) not Equal is printed (c) equal is printed and not Equal is printed (d) Nothing is printed. 17. This statement i++ is equal to? A. i = 1 + 1; B. i = total + 1; C. i = i + 1; D. None of the above E. Two of the above 18. What is the result? for(int i = 0; i < array.length; i++) array[i] = i + 2; System.out.println(array[i]); A. 0, 0, 0, 0, 0 B. 2, 4, 6, 8, 10 C. 2, 3, 4, 5, 6 D. 0 E. None of These 19. Which one is a logical Bitwise OR? A. && B. I C. II D. ^ E. None of these 20. Logical bitwise OR performs which of the following A. Test both sides all the time B. Test only one side, if needed test other side C. Test only right side D. If one side is True , then other side must be False for a True result E. If one side is True, then other side must be True for a True result 21. Why might you use a static modifier for a method? A. Because you need to create an object to use it B. Because you don’t need to create an object to use it C. Because only static methods can call other static methods. D. Two of the above E. None of the above 22. A method with a public access modifier can be seen by? A. Everyone B. Class only C. Package only D. No one 23. A method with a private access modifier can be seen by? A. Everyone B. Class only C. Package only D. No one 24. A method with a protected/default access modifier can be seen by who? A. Everyone B. Class only C. Package only D. No one 25. Which one is a valid way to declare an Array? A. double[] array = new double[5]; B. double array[] = new double[5]; C. double array; D. Two of the above E. All of the above 26. What is the default value for values in an uninitialized int array? A. Garbage B. Null C. 0 D. Compile error, all arrays must initialized E. Trick question, all arrays ask you to initialized them when you first use them 27. Evaluate the if statement int x = 14; if(x < 3 * 4 + 6 / 3 && 5 > 2 * 3 || 12 <= 9 + 3 || x!=10 ^ true ) A. True B. False C. Compile error D. 0 E. 1 28. What is the value of discount? double discount; char code = 'C' ; switch ( code ) { case 'A': discount = 0.0; break; case 'B': discount = 0.1; break; case 'C': discount = 0.2; default: discount = 0.3; } A. 0.0 B. 0.1 C. 0.2 D. 0.3 E. Compile error 29. Which variable ‘a’ gets assigned 6, when the method is called? public class test{ int a; public void myMethodA(int a){ a = 6; } } A. The variable inside the method B. The variable outside the method C. Compile error, cannot have two variables with the same name D. Both will have the value of 6 E. None of these 30. Which loop is best for running at least once? A. For loop B. While loop C. Do-While Loop D. Enhanced For Loop E. Fruit loops 31. Which loop is best for initializing arrays? A. For Loop B. While Loop C. Do-While Loop D. Enhanced For Loop E. Fruit Loops 33. Given the following variables char c = 'c'; int i = 10; double d = 10; long l = 1; String s = "Hello"; Which of the following will compile without error? A. c=c+i; B. s+=i; C. i+=s; D. c+=s; Attachments


Java - Programming - Answers


Attached are the answers with short explanations on some. Please let me know if you need any further clarification. Attachments
answers.txt (1 K) Download Preview
to use it 22) A. Everyone 23) B. Class only 24) C. Package only 25) D. Two of the above 26) C. 0 27) C. Compile error 28) D. 0.3 29) A. The variable inside the method 30)

Purchase Answer