Java Quiz October 6, 2024 | No Comments 0 votes, 0 avg 318 123456789101112131415 Java Questions 1 / 15 1. What does Object Oriented Programming means? A. Writing a program composed of java classes B. Writing an algorithm before writing your program and having a test plan C. Being objective about what you develop D. Desigining the application based on the objects discovered when analysing the problem 2 / 15 2. Which environment variable is used to set the java path? A. MAVEN_Path B. JavaPATH C. JAVA D. JAVA_HOME 3 / 15 3. Which variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed? A. Local variables B. Instance variables C. Class Variables D. Static variables 4 / 15 4. Which constructor creates an empty string buffer with the specified capacity as length. A. StringBuffer() B. StringBuffer(String str) C. StringBuffer(int capacity) D. none of the above 5 / 15 5. Find the output of the following code. Public class Solution{ Public static void main(String args[]){ Int i; for(i = 1; i < 6; i++){ if(i > 3) continue; } System.out.println(i); } } A. 3 B. 4 C. 5 D. 6 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. What will be the output of the following Java program? class Output { public static void main(String args[]) { int arr[] = {1, 2, 3, 4, 5}; for ( int i = 0; i < arr.length - 2; ++i) System.out.println(arr[i] + " "); } } A. 1 2 3 4 5 B. 1 2 3 4 C. 1 2 D. 1 2 3 8 / 15 8. File class is included in which package? A. java.io package B. java.util.package C. java.lang package D. java.net.package 9 / 15 9. Which of the following are not java modifiers? A. public B. private C. friendly D. transient 10 / 15 10. What is true about final class? A. class declared final is a final class B. final classes are created so the methods implemented by that class cannot be overidden C. It can’t be inherited D. all of the above 11 / 15 11. Which of the following is true about public access modifier? A. Variables, methods and constructors which are declared public can be accessed by any class B. Variables, methods and constructors which are declared public can be accessed by any class lying in same pacckage. C. Variables, methods and constructors which are declared public in the superclass can be accessed only by it’s child class. D. none of the above 12 / 15 12. Where does the system stores parameters and local variables whenever a method is invoked? A. Heap B. Stack C. Array D. Tree 13 / 15 13. 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 14 / 15 14. What is not the use of “this” keyword in Java? A. Passing itself to the method of the same class B. Referring to the instance variable when a local variable has the same name C. Passing itself to another method D. Calling another constructor in constructor chaining 15 / 15 15. Find the output of the following program. public class Solution{ public static void main(String[] args){ short x = 10; x = x * 5; System.out.print(x); } } A. Compilation error B. 50 C. 10 D. Exception Your score isThe average score is 36% LinkedIn Facebook VKontakte 0% Restart quiz By Wordpress Quiz plugin Quiz