java exam 0 votes, 0 avg 7 123456789101112131415 Java Questions 1 / 15 1. What is Truncation in Java? A. Floating-point value assigned to an integer type B. Integer value assigned to floating type C. Floating-point value assigned to a Floating type D. Integer value assigned to an integer type 2 / 15 2. Which data type value is returned by all transcendental math functions? A. int B. float C. double D. long 3 / 15 3. What will be the output of the following Java program? class A { int i; public void display() { System.out.println(i); } } class B extends A { int j; public void display() { System.out.println(j); } } class Dynamic_dispatch { public static void main(String args[]) { B obj2 = new B(); obj2.i = 1; obj2.j = 2; A r; r = obj2; r.display(); } } A. 1 B. 2 C. 3 D. 4 4 / 15 4. Which of these is returned by “greater than”, “less than” and “equal to” operators? A. Integers B. Floating – point numbers C. Boolean D. None of the mentioned 5 / 15 5. What will be the output of the following Java program? class Output { public static void main(String args[]) { double x = 2.0; double y = 3.0; double z = Math.pow( x, y ); System.out.print(z); } } A. 9.O B. 8.O C. 4.O D. 2.O 6 / 15 6. Which of the following is a type of polymorphism in Java? A. Compile time polymorphism B. Execution time polymorphism C. Multiple polymorphism D. Multilevel polymorphism 7 / 15 7. Which statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression? A. If B. Switch C. Nested-if D. If-else-if 8 / 15 8. What will be the output of the following Java code snippet? class abc { public static void main(String args[]) { if(args.length>0) System.out.println(args.length); } } A. The snippet compiles and runs but does not print anything B. The snippet compiles, runs and prints 0 C. The snippet compiles, runs and prints 1 D. The snippet does not compile 9 / 15 9. Which exception is thrown when java is out of memory? A. MemoryError B. OutOfMemoryError C. MemoryOutOfBoundsException D. MemoryFullException 10 / 15 10. Which concept of Java is achieved by combining methods and attribute into a class? A. Encapsulation B. Inheritance C. Polymorphism D. Abstraction 11 / 15 11. How many objects will be created in the following? String a = new String(“Interviewbit”); String b = new String(“Interviewbit”); Strinc c = “Interviewbit”; String d = “Interviewbit”; A. 2 B. 3 C. 4 D. none 12 / 15 12. Which of the following is true in regard to applet execution? A. Applets loaded and executing locally have some restrictions faced by applets that get loaded from the network. B. Applets loaded and executing locally have none of the restrictions faced by applets that get loaded from the network. C. Applets loaded from the same computer where they are executing have the same restrictions as applets loaded from the network. D. Applets cant react to user input and change dynamically 13 / 15 13. How to format date from one form to another? A. SimpleDateFormat B. DateFormat C. SimpleFormat D. DateConverter 14 / 15 14. What will be the output of the following Java code? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o')); } } A. 6 4 6 9 B. 5 4 5 9 C. 7 8 8 9 D. 4 3 6 9 15 / 15 15. Choose the appropriate data type for this field: isSwimmer A. double B. boolean C. string D. int Your score is The average score is 19% LinkedIn Facebook Twitter VKontakte 0% Restart quiz