Java Basics Quiz
JAVA Basics Quiz
10 XPjava Basics Quiz
Views | |
---|---|
1849 | Total Views |
4 | Members Views |
1845 | Public Views |
Actions | |
---|---|
0 | Likes |
0 | Dislikes |
0 | Comments |
Share by mail
Please login to share this quiz by email.
1. What is float datatype?
2. Which Feature of OOP illustrated the code reusability?
3. Which of the following best defines a class?
4. What is the additional feature in classes that was not in structures?
5. Which of the two features match each other?
6. If same message is passed to objects of several different classes and all of those can respond in a different way, what is this feature called?
7. Which feature can be implemented using encapsulation?
8. Which among the following best describes encapsulation?
It is a way of combining various data members into a single unit
It is a way of combining various member functions into a single unit
It is a way of combining various data members and member functions into a single unit which can operate on any data
It is a way of combining various data members and member functions that operate on those data members into a single unit
10. Which is the correct flow?
11. Which are the compatible Data Types for Type Promotion or Type Casting?
12. What is the output of the below Java code snippet?char ch = 'A'; int a = ch +1; ch = (char)a; System.out.println(ch)
15. In Java arrays are
16. Which one of the following is a valid statement?
17. Which among the following is true?
18. Which access specifier is used when no access specifier is used with a member of class (java)?
19. Which specifier allows a programmer to make the private members which can be inherited?
20. Which among the following is correct?
21. Which among the following best describes constructor overloading?
22. Which is correct syntax for creating objects?
23. Which among the following best defines static variables members?
24. The static members are
25. How can you make the private members inheritable?
26. Which is the correct syntax of inheritance?
27. An abstract class can have
28. If there is an abstract method in a class then, ________________
29. Which of the following is the correct way of implementing an interface salary by class manager?
30. Which of these access specifiers can be used for an interface?
31. Which of these is a mechanism for naming and visibility control of a class and its content?
32. Which of the following is the correct way of importing an entire package ‘pkg’
33. public class MethodDemo { public String message = "Hi"; public void displayName(){ System.out.println(" MethodDemo "); } public static void main(String[] args) { displayName(); System.out.println(message); } }
34. class MethodDemo { int counter = 10; public static void main (String Args[]){ counter =22; System.out.println("counter value" +counter); } }
35. public class MethodDemo{ public String message = "Hi"; public void displayName(){ System.out.println(" MethodDemo "); } public static void main(String[] args) { MethodDemo demo = new MethodDemo (); demo.displayName(); } }
36. Create a list containing string,integer and an Employee object import java.util.List; import java.util.ArrayList; class Employee{} public class ArrayListDemo { public static void main(String[] args) { //Your code // // // for(int index=0 ; index<list.size() ; index++) System.out.println(" "+ index + " : " + list.get(index) ); } }
List list = new ArrayList(); list.add("Hi"); list.add(new Integer(100)); list.add(new Employee());
List list() = new ArrayList;list.add("Hi");list.add(new Integer(100));list.add(new Employee());
List list = new ArrayList; list.add("Hi"); list.add(new Integer(100)); list.add(new Employee());
None of the above
37. public class Test { public static void main(String[] args) { try { System.out.printf("1"); int data = 5 / 0; } catch(ArithmeticException e) { System.out.printf("2"); System.exit(0); } finally { System.out.printf("3"); } System.out.printf("4"); } }
38. public class Test{ public static void main(String args[]){ int i; try{ i=find(); System.out.println(i); }catch(Exception e){ System.out.println(“Error Occurred”); } }static int find(){ return(9/2); }}
39. class MyClass{ public String test(){ try{ System.out.println(“one”); return “ “; }finally{ System.out.println(“two”); }}} public class Test{ public static void main(String args[]){ Myclass m=new Myclass(); m.test(); }}
40. Which among the following is true?
If catch block of base class is written first, it is compile time error
If catch block of base class is written first, it is run time error
If catch block of base class is written first, derived class catch block can’t be reached
If catch block of base class is written first, derived class catch block can’t be reached
41. What is the output of the following program? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v')); } }
42. What will be the output of the following program? public class Shock { public static void main(String[] args) { Long abc = 200L; Long bca = 199L; Long cab = 100L; if ((abc > bca) ^ ((cab * 3) == abc)) System.out.print("ABC"); else if ((bca + 1 != abc) ^ ((cab * 3) == bca)) System.out.print("BCA"); System.out.print("CAB"); }
44. What is the output of the following program? class Main { public static void main(String args[]) { Double x = new Double(10); double i = x.doubleValue(); System.out.print(i + " " + x); } }
45. public class WrapperExample1{ public static void main(String args[]){ int a=20; Integer i=Integer.valueOf(a); Integer j=a; System.out.println(a+" "+i+" "+j); }}
46. What will be the output of the following Java program?import java.util.*; class Array { public static void main(String args[]) { int array[] = new int [5]; for (int i = 5; i > 0; i--) array[5-i] = i; Arrays.fill(array, 1, 4, 8); for (int i = 0; i < 5 ; i++) System.out.print(array[i]); } }
47. Which of this interface is not a part of Java’s collection framework?
48. What is the difference between length() and size() of ArrayList?
49. Which interface does java.util.Hashtable implement?
50. What is the length of the application box made in the following Java program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { Graphic g; g.drawString("A Simple Applet",20,20); }
51. public class Test { public static void main(String[] args) { int count = 1; while (count <= 15) { System.out.println(count % 2 == 1 ? "*" : "+++++"); ++count; } // end while } // end main }
52. What is the output of the following program? import java.util.*; public class priorityQueue { public static void main(String[] args) { PriorityQueue<Integer> queue = new PriorityQueue<>(); queue.add(11); queue.add(10); queue.add(22); queue.add(5); queue.add(12); queue.add(2); while (queue.isEmpty() == false) System.out.printf("%d ", queue.remove()); System.out.println("\n"); } }
53. What is the output of the following program? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v')); } }