java Basics Quiz
Views
1082 Total Views
4 Members Views
1078 Public Views
Actions
0 Likes
0 Dislikes
0 Comments
Share on Social Networks
Share Link
Use permanent link to share in social media
Share by mail

Please login to share this quiz by email.

2. Which Feature of OOP illustrated the code reusability?
4. What is the additional feature in classes that was not in structures?
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?
9. Java allow , Same java program program to be executed on multiple operating systems.
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)
13. From which index does the array of objects start?
14. What is the type of elements of array of objects?
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?
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) ); } }
37. public class Test { public static void main(String[] args) { try { System.out.printf(&quot;1&quot;); int data = 5 / 0; } catch(ArithmeticException e) { System.out.printf(&quot;2&quot;); System.exit(0); } finally { System.out.printf(&quot;3&quot;); } System.out.printf(&quot;4&quot;); } }
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(); }}
41. What is the output of the following program? class output { public static void main(String args[]) { String a = &quot;hello i love java&quot;; System.out.println(a.indexOf(&#39;e&#39;)+&quot; &quot;+a.indexOf(&#39;a&#39;)+&quot; &quot;+a.lastIndexOf(&#39;l&#39;)+&quot; &quot;+a.lastIndexOf(&#39;v&#39;)); } }
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 &gt; bca) ^ ((cab * 3) == abc)) System.out.print(&quot;ABC&quot;); else if ((bca + 1 != abc) ^ ((cab * 3) == bca)) System.out.print(&quot;BCA&quot;); System.out.print(&quot;CAB&quot;); }
43. Which of these is a super class of Character wrapper?
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 + &quot; &quot; + 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+&quot; &quot;+i+&quot; &quot;+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 &gt; 0; i--) array[5-i] = i; Arrays.fill(array, 1, 4, 8); for (int i = 0; i &lt; 5 ; i++) System.out.print(array[i]); } }
47. Which of this interface is not a part of Java’s collection framework?
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(&quot;A Simple Applet&quot;,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 = &quot;hello i love java&quot;; System.out.println(a.indexOf(&#39;e&#39;)+&quot; &quot;+a.indexOf(&#39;a&#39;)+&quot; &quot;+a.lastIndexOf(&#39;l&#39;)+&quot; &quot;+a.lastIndexOf(&#39;v&#39;)); } }