You are on page 1of 10

1) When does the JVM exit? B) When a thread executes System.

exit(); C) After all the non deamons threads created by the application complete. 2) Which of the following are correct event handling methods A) mousePressed(MouseEvent e){} C) componentAdded(ContainerEvent e){} 3) Which of the following are methods of the Collection interface? B) iterator C) toArray D) isEmpty 4) Which of the following are true? B) The ActionListener interface has no corresponding Adapter class C) An event listener may be removed from a component 5) Which of the following keywords can be applied to the variables or methods of an interface B) static C) public 6) In order to distribute Java applets, you require B) The applet in .class format 7) A Java program typically runs D) Faster than a program written in a shell script language, but slower than a program in a native language such as C 8) If X and Y are objects, and you write X = Y; in your code, it means: D) Set X to refer to the same object as Y 9) In the Abstract Windowing Toolkit, the origin of a frame is always at B) Top Left 10) You want to loop through an array and stop when you come to the last element. Being a good java programmer and forgetting everything you ever knew about C/C++ you know that arrays contain information about their size. Which of the following can you use? B) myarray.length; 11) If you synchronise two methods, they B) won't both access the same object at the same time 12) JAR automatically creates a manifest file even if it is not specified B) False 13) Which of following is correct C) Private methods cannot be accessed by different classes 14) What is the output of the following fragment of code? int array[] = new int[5]; int i=0;

int length =array.length; for(i=0;i<length;i++){ array = new int[i+1]; array[i]=i; } for(i=0;i<array.length-1;i++){ System.out.print(array[i]+ , ); } C) 0,0,0,0, 15) Which of the following statements are true? B) The garbage collection algorithm in Java is vendor implemented 16) Data Encapsulation is a process of B) All of above 17) Servlets are Java programs that can run on an end-users browser B) False 18) ___refers to the ability of the program to move from one computer to another, without any difficulty D) Platform independent 19) Which of the following applet tags are mandatory (select all the correct answers) A) CODE B) HEIGHT D) WIDTH 20) All the standard Java classes included in Java are stored in a package called B) java 21) For a class if you do not define a constructor then the JVM provides a default (or called also implicit) constructor B) True 22) How many methods does the MouseMotionListener interface define? C) 2 23) Consider the following piece of code. 1. String s = "abcd"; 2. Integer x = new Integer(3); 3. String s2 = s + 4; 4. s2 = null; 5. s = null; Following the execution of which line above, is the object referenced by s2 available for garbage collection? B) Line 4 24) Consider the following piece of code and select the correct statement from the following. String s = new String("abcdefgh"); // (1) s.replace('d', 'q'); // (2) System.out.println(s); // (3) D) The code compiles correctly, and displays the text "abcdefgh" 25)

Consider the following piece of code and select the correct statement(s): 1. class A{ 2. protected int method(){ 3. } 4. } 5. 6. class B extends A{ 7. int method(){ 8. } 9. } A) The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier "public" B) The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier "protected" D) The code fails to compile, because you can't override a method to be more private than its parent 26) To find how wide a character string will appear in your AWT window, use C) the stringWidth method on a FontMetrics object 27) The statement int [] counts = new int [26]; B) Creates an array object that can hold up to 26 whole numbers 28) In order to move smoothly from one graphics frame to the next, you need C) to draw to an offscreen canvas and then copy the canvas in a single call to the drawImage method 29) The original Java programming research project was code named? B) Green 30) Which of the following statements are true? D) Constructors are not inherited 31) In Java, inheritance permits a class to inherit the attributes and operations from more than one class B) False 32) Java Bytecode can run on every platform with the help of ___ C) Java Virtual Machine 33) The ___ is the default layout manager for applets and panels B) Flow Layout 34) What is the default Layout Manager for applets? B) FlowLayout 35) Which of the following classes can be used to manage a collection of elements, with no duplication D) Hashtable 36) Which of the following are valid ways to define an abstract method D) abstract void Test(); 37) The code in the finally block is only invoked when error conditions do not occur. Is it TRUE or FALSE B) false

38) Choose the best description of abstract method: B) Abstract methods dont have implementation 39) Local variables can be used only within the given class B) false 40) Java error handling model can handle C) runtime-error 41) Multiple inheritance can be allowed in Java in some specific circumstances B) false 42) Which of those methods belong to the applet class? A) start() C) stop() D) init() 43) The mechanism that permits a class to share the atrributes and operations defined in one or more classes is called: B) Inheritance 44) The ability of an object to store data beyond the lifetime of the object is known as B) Persistence 45) ___ allows a class to have several superclasses B) Interface 46) Which of the following are legal names for variables D) Integer 47) A member which is to be visible within the same class, other classes in the same package, and also subclasses, but NOT in other classes which are in different packages and are not subclasses, is declared as: B) protected 48) In Java, objects are essentially? B) reusable software components 49) Choose wrong statements in the following list of Java features B) JDK is an integrated development environment developed for Java by Microsoft C) Multiple inheritance is allowed in Java D) Java is a platform dependent language 50) You have a public class called myclass with the main method defined as follows public static void main(String parm[]){ System.out.println(parm[0]); } If you attempt to compile the class and run the program as follows java myclass hello What will happen? C) Compilation and output of hello 51) Which of the following are valid methods?

A) static native void amethod(); C) public static void amethod(){} 52) Which package provides classes and functions that can be used to create a GUI such that it is platform independent? C) awt 53) Which are related to the main thread? (choose three) A) It is the thread from which child threads will be created C) It is the last thread to finish execution D) The moment the main thread stops executing, the program is terminated 54) Which is the correct range of thread priority? D) 1 10 55) Which of the following statements are valid, given the following variable declarations: boolean a; boolean b; int c; C) (a || a) 56) Which of the following layouts places components in rows and columns and all components are of the same size B) GridLayout 57) ___ is a folder under which you organize your classes and interfaces B) Package 58) ___ is the process of hiding the implementation details of an object from its user D) Encapsulation 59) Consider the following piece of code (assume the Graphics context g is defined correctly): g.setBackground(Color.red); g.setForeground(Color.white); g.drawLine(10, 10, 50, 10); g.setForeground(Color.blue); g.drawRect(100, 100, 50, 50); What is displayed when this code is executed D) Compile error 60) What is the output of the following piece of code: 1. int x = 6; 2. double d = 7.7; 3. 4. System.out.println((x > d) ? 99.9 : 9); C) 9.0 61) Choose the best phrase for the below statement: Java uses to store packages C) file-system directories 62) Using interfaces, you will be able to specify what a class must do, but not how it does that particular task B) true 63) For a class if you do not define a constructor then the JVM provides a default (or called also implicit) constructor

B) True 64) Every class has only one constructor and one destructor B) False 65) A variable of type char can take how may different values? D) 128 66) Which of these is a predefined colour? C) Color.darkGray 67) If you synchronise two methods, they C) won't both access the same object at the same time 68) What will happen when you attempt to compile and run the following code snippet? String str = "Java"; StringBuffer buffer = new StringBuffer (str); if (str.equals(buffer)) { System.out.println ("Both are equal"); } else { System.out.println ("Both are not equal"); } C) Prints "Both are not equal" 69) ___ is the process of identifying and grouping attributes and actions related to a particular entity B) Data Abstraction 70) Choose the roles of the key word throw (Choose one) C) Indicates that an exception has occurred 71) ___ methods are in the same class and have the same name, but different parameter lists B) Overloaded 72) Which of followings is abstract class (Choose two) B) FilterOutputStream D) FilterInputStream 73) The two methods used to reduce flicker are B) Override update() methods; and using double buffering 74) What is the relation between thread priority and thread scheduling? C) Thread priority is used to determine the next thread to execute from the waiting thread pool 75) Choose the roles of the key word throw (Choose one) C) Indicates that an exception has occurred 76) Untrusted code (i.e. that has been downloaded by a browser) can ONLY do one of the following. Which? C) Read the os.name system property to find the name of the operating system it is running on 77)

A class which has all its constructors declared as private B) Cannot be instantiated by any other class 78) What will happen when you attempt to compile and run this code //Demonstration of event handling import java.awt.*; import java.awt.event.*; public class MyWc extends Frame implements WindowListener{ public static void main(String argv[]){ MyWc mwc = new MyWc(); } public void windowClosing(WindowEvent we){ System.exit(0); }//End of windowClosing public void MyWc(){ setSize(300,300); setVisible(true); } }//End of class B) Error at compile time 79) The single Java programs can function both as an applet and an application B) True 80) Which of the following names of variable are valid in Java? (choose two) B) function1 C) label D) $name1 81) Java source code when compiled results in a file with extension B) .class 82) Which of the followings are illegal identifier B) EmpnoEmp.no 83) Which of the following statements are true? B) Interfaces are the Java approach to addressing its lack of multiple inheritance, but require implementing classes to create the functionality of the Interfaces D) Interfaces cannot have constructors 84) Which of the following statements are true? B) All of the variables in an interface are implicitly static C) All of the methods in an interface are implicitly abstract D) All of the variables in an interface are implicitly final 85) To find how wide a character string will appear in your AWT window, use D) the stringWidth method on a FontMetrics object 86) Which layout manager would you use to lay out a regular set of buttons, such as a telephone dial pad? D) grid 87) Which of the following are legal statements? (Choose all that apply) B) int i=1/3;

C) double d=999d; D) float f=1/3; 88) Which of the following are valid statements C) Math.max(s); 89) Which of those are the types of threads in a Java program? B) Daemon C) User Thread 90) GUI system handles all user interactions with the help of ___ B) event-driven model 91) Which of following classes are not a non-abstract class of java.util C) Hashtable 92) Consider the following piece of code. class Test{ public static void main(String [] args){ System.out.println(args[3]); } } When the following is typed at the command line, what is displayed: java Test Metallica Justice For All B) All 93) Analyse the following 2 classes and select the correct statements. class A{ private int x = 0; static int y = 1; protected int q = 2; } class B extends A{ void method(){ System.out.println(x); System.out.println(y); System.out.println(q); } } A) Removing the line "System.out.println(x)" will allow the code to compile correctly C) The code fails to compile because the variable x is not available to class B D) The compiler will complain that the variable x in class B is undefined 94) Which Utility class would you use if you want to have an array which can be extended dynamically while your Java program runs? C) A Vector 95) ___ method notifies the thread that is currently in the waiting state. B) Notify() C) NotifyAll() 96) The ___ loop executes certain statements at least once, even if the specified condition is the False C) do - while

97) Which of the following retain their preferred size (width and height) when added (individually) to the North section of a container with a BorderLayout (assume that no other components or containers are present in the North section) B) Checkbox 98) An applet is C) A piece of Java running within a web browser 99) Interface methods can be declared with the following modifiers A) public C) none (i.e., no access modifier) 100) Which of the following are true? B) The ActionListener interface has no corresponding Adapter class C) An event listener may be removed from a component 101) Which of the following statements are true? C) Constructors are not inherited 102) Which of the following statements are true? B) An interface cannot be instantiated C) A inner class may under some circumstances be defined with the protected modifier 103) ___ is a folder under which you organize your classes and interfaces C) Package 104) An exception is always C) an instance of class Throwable 105) What is sent to System.out by this code: Int val = 11; System.out.print("Result: "+val+1); C) Result: 111 106) Which of the following statements are true? C) A byte can represent between -128 to 127 107) Which of the following method allows to retrieve the text of a TextField
C) getText()2)

108) From how many classes can you inherit methods directly into a subclass? C) 1 109) The wait( ) method does the following? D) Blocks until notified by another thread 110) Which of the following methods are defined in the Label Class B) setText(String s) C) setFont(Font f) 111) Which of these statements is wrong? D) A static variable is one which cannot be changed once initialised 112)

Which of following are not valid Java identifiers? B) 2nd_level C) hook&lader 113) Which of the following statements are true? A) When applied to a class, the final modifier means it cannot be sub-classed C) transient and volatile are Java modifiers D) If a class has any abstract methods it must be declared abstract itself 114) Which of the following statements are true? A) static methods do not have access to the implicit variable called this C) A static method may not be overriden to be non-static D) A static method may be called without creating an instance of its class 115) Which of the following statement related to interfaces are True B) Interface can extend other interfaces 116) Choose two right statements about excpetion A) An exception occurs at runtime in a code sequence C) Every exception handling allows you to combine all error processing in one place 117) What is the name of the interface that can be used to define a class that can execute within its own thread? F) None of above 118) Which of the following terminates a thread execution? B) All of above 119) Java exception-handling only captures errors caused by user programs like invalid input, open non-existent file etc C) false 120) Which of the following statements are true? A) transient and volatile are Java modifiers C) If a class has any abstract methods it must be declared abstract itself. D) When applied to a class, the final modifier means it cannot be sub-classed 121) Which of the following can be applied to constructors B) None of these 122) Which modifier should be placed to interface definition in order to make this interface only available to other members of the package to which it is declare? Choose one of the following modifiers B) None of them 123) Java Vitual Machine is responsible for C) interpretation and running of the byte code

You might also like