tong hop de thi gaj

Upload: volaithusinh

Post on 14-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 Tong hop de thi GAJ

    1/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 methodsA) mousePressed(MouseEvent e){}C) componentAdded(ContainerEvent e){}3)

    Which of the following are methods of the Collection interface?B) iteratorC) toArrayD) isEmpty4)Which of the following are true?B) The ActionListener interface has no corresponding Adapter classC) An event listener may be removed from a component5)Which of the following keywords can be applied to the variables or methods of an interfaceB) static

    C) public6)In order to distribute Java applets, you requireB) The applet in .class format7)A Java program typically runsD) Faster than a program written in a shell script language, but slower than a program in a native language suchas C8)If X and Y are objects, and you writeX = Y;

    in your code, it means:D) Set X to refer to the same object as Y9)In the Abstract Windowing Toolkit, the origin of a frame is always atB) Top Left10)

    You want to loop through an array and stop when you come to the last element. Being a goodjava programmer and forgetting everything you ever knew about C/C++ you know that arrayscontain information about their size. Which of the following can you use?B) myarray.length;11)

    If you synchronise two methods, theyB) won't both access the same object at the same time12)JAR automatically creates a manifest file even if it is not specifiedB) False13)Which of following is correctC) Private methods cannot be accessed by different classes14)What is the output of the following fragment of code?int array[] = new int[5];int i=0;

  • 7/29/2019 Tong hop de thi GAJ

    2/10

    int length =array.length;for(i=0;i

  • 7/29/2019 Tong hop de thi GAJ

    3/10

    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 accessqualifier "public"B) The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the accessqualifier "protected"D) The code fails to compile, because you can't override a method to be more private than its parent26)To find how wide a character string will appear in your AWT window, useC) the stringWidth method on a FontMetrics object27)The statement int [] counts = new int [26];

    B) Creates an array object that can hold up to 26 whole numbers28)In order to move smoothly from one graphics frame to the next, you needC) to draw to an offscreen canvas and then copy the canvas in a single call to the drawImage method29)The original Java programming research project was code named?B) Green30)Which of the following statements are true?D) Constructors are not inherited31)

    In Java, inheritance permits a class to inherit the attributes and operations from more than oneclassB) False32)Java Bytecode can run on every platform with the help of ___C) Java Virtual Machine33)The ___ is the default layout manager for applets and panelsB) Flow Layout34)What is the default Layout Manager for applets?

    B) FlowLayout35)Which of the following classes can be used to manage a collection of elements, with noduplicationD) Hashtable36)Which of the following are valid ways to define an abstract methodD) abstract void Test();37)The code in the finally block is only invoked when error conditions do not occur. Is it TRUE orFALSEB) false

  • 7/29/2019 Tong hop de thi GAJ

    4/10

    38)Choose the best description of abstract method:B) Abstract methods dont have implementation39)Local variables can be used only within the given classB) false40)Java error handling model can handleC) runtime-error

    41)Multiple inheritance can be allowed in Java in some specific circumstancesB) false42)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 ormore classes is called:

    B) Inheritance44)The ability of an object to store data beyond the lifetime of the object is known asB) Persistence45)

    ___ allows a class to have several superclassesB) Interface46)Which of the following are legal names for variablesD) Integer47)

    A member which is to be visible within the same class, other classes in the same package, andalso subclasses, but NOT in other classes which are in different packages and are notsubclasses, is declared as:B) protected48)In Java, objects are essentially?B) reusable software components49)Choose wrong statements in the following list of Java featuresB) JDK is an integrated development environment developed for Java by MicrosoftC) Multiple inheritance is allowed in Java

    D) Java is a platform dependent language50)You have a public class called myclass with the main method defined as followspublic 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 helloWhat will happen?C) Compilation and output of hello51)Which of the following are valid methods?

  • 7/29/2019 Tong hop de thi GAJ

    5/10

    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 isplatform independent?C) awt53)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 executionD) The moment the main thread stops executing, the program is terminated54)Which is the correct range of thread priority?D) 1 1055)Which of the following statements are valid, given the following variable declarations: booleana; boolean b; int c;C) (a || a)56)Which of the following layouts places components in rows and columns and all components a

    of the same sizeB) GridLayout57)

    ___ is a folder under which you organize your classes and interfacesB) Package58)

    ___ is the process of hiding the implementation details of an object from its userD) Encapsulation59)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 executedD) Compile error60)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.061)Choose the best phrase for the below statement: Java uses to store packagesC) file-system directories62)Using interfaces, you will be able to specify what a class must do, but not how it does thatparticular taskB) true63)For a class if you do not define a constructor then the JVM provides a default (or called alsoimplicit) constructor

  • 7/29/2019 Tong hop de thi GAJ

    6/10

    B) True64)Every class has only one constructor and one destructorB) False65)A variable of type char can take how may different values?D) 12866)Which of these is a predefined colour?

    C) Color.darkGray67)If you synchronise two methods, theyC) won't both access the same object at the same time68)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 particularentityB) Data Abstraction70)

    Choose the roles of the key word throw (Choose one)C) Indicates that an exception has occurred71)

    ___ methods are in the same class and have the same name, but different parameter listsB) Overloaded72)Which of followings is abstract class (Choose two)B) FilterOutputStreamD) FilterInputStream73)The two methods used to reduce flicker are

    B) Override update() methods; and using double buffering74)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 pool75)Choose the roles of the key word throw (Choose one)C) Indicates that an exception has occurred76)Untrusted code (i.e. that has been downloaded by a browser) can ONLY do one of the followingWhich?C) Read the os.name system property to find the name of the operating system it is running on77)

  • 7/29/2019 Tong hop de thi GAJ

    7/10

    A class which has all its constructors declared as privateB) Cannot be instantiated by any other class78)What will happen when you attempt to compile and run this code

    //Demonstration of event handlingimport 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 classB) Error at compile time

    79)The single Java programs can function both as an applet and an applicationB) True80)Which of the following names of variable are valid in Java? (choose two)B) function1C) labelD) $name181)Java source code when compiled results in a file with extensionB) .class

    82)Which of the followings are illegal identifierB) EmpnoEmp.no83)Which of the following statements are true?B) Interfaces are the Java approach to addressing its lack of multiple inheritance, but require implementingclasses to create the functionality of the InterfacesD) Interfaces cannot have constructors84)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 abstractD) All of the variables in an interface are implicitly final85)To find how wide a character string will appear in your AWT window, useD) the stringWidth method on a FontMetrics object86)Which layout manager would you use to lay out a regular set of buttons, such as a telephonedial pad?D) grid87)Which of the following are legal statements? (Choose all that apply)B) int i=1/3;

  • 7/29/2019 Tong hop de thi GAJ

    8/10

    C) double d=999d;D) float f=1/3;88)Which of the following are valid statementsC) Math.max(s);89)Which of those are the types of threads in a Java program?B) DaemonC) User Thread

    90)GUI system handles all user interactions with the help of ___B) event-driven model91)Which of following classes are not a non-abstract class of java.utilC) Hashtable92)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 AllB) All93)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 correctlyC) The code fails to compile because the variable x is not available to class BD) 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 extendeddynamically while your Java program runs?C) A Vector95)

    ___ 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 theFalseC) do - while

  • 7/29/2019 Tong hop de thi GAJ

    9/10

    97)Which of the following retain their preferred size (width and height) when added (individually) tthe North section of a container with a BorderLayout (assume that no other components orcontainers are present in the North section)B) Checkbox98)An applet isC) A piece of Java running within a web browser99)

    Interface methods can be declared with the following modifiersA) publicC) none (i.e., no access modifier)100)Which of the following are true?B) The ActionListener interface has no corresponding Adapter classC) An event listener may be removed from a component101)Which of the following statements are true?C) Constructors are not inherited102)

    Which of the following statements are true?B) An interface cannot be instantiatedC) A inner class may under some circumstances be defined with the protected modifier103)

    ___ is a folder under which you organize your classes and interfacesC) Package104)An exception is alwaysC) an instance of class Throwable105)What is sent to System.out by this code:

    Int val = 11;System.out.print("Result: "+val+1);C) Result: 111106)Which of the following statements are true?C) A byte can represent between -128 to 127107)Which of the following method allows to retrieve the text of a TextFieldC) getText()2)

    108)From how many classes can you inherit methods directly into a subclass?C)1109)The wait( ) method does the following?D) Blocks until notified by another thread110)Which of the following methods are defined in the Label ClassB) 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 initialised112)

  • 7/29/2019 Tong hop de thi GAJ

    10/10

    Which of following are not valid Java identifiers?B) 2nd_levelC) hook&lader113)Which of the following statements are true?A) When applied to a class, the final modifier means it cannot be sub-classedC) transient and volatile are Java modifiersD) If a class has any abstract methods it must be declared abstract itself114)

    Which of the following statements are true?A) static methods do not have access to the implicit variable called thisC) A static method may not be overriden to be non-staticD) A static method may be called without creating an instance of its class115)Which of the following statement related to interfaces are TrueB) Interface can extend other interfaces116)Choose two right statements about excpetionA) An exception occurs at runtime in a code sequenceC) 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 itsown thread?F) None of above118)Which of the following terminates a thread execution?B) All of above119)Java exception-handling only captures errors caused by user programs like invalid input, opennon-existent file etcC) false

    120)Which of the following statements are true?A) transient and volatile are Java modifiersC) 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-classed121)Which of the following can be applied to constructorsB) None of these122)Which modifier should be placed to interface definition in order to make this interface onlyavailable to other members of the package to which it is declare? Choose one of the following

    modifiersB) None of them123)Java Vitual Machine is responsible forC) interpretation and running of the byte code