OCJP Certification Sample Question Set-8

    Spread the love
    • 1

    OCJP Certification Sample Question Set-8
    OCJP Certification Sample Question Set-8

    OCJP Certification Sample Question Set-8:

    Applet Related:

    What is an Applet? Should applets have constructors?
    Ans : Applet is a dynamic and interactive program that runs inside a Web page
    displayed by a Java capable browser. We don’t have the concept of Constructors in Applets.

    How do we read number information from my applet’s parameters, given that Applet’s getParameter() method returns a string?
    Ans : Use the parseInt() method in the Integer Class, the Float(String) constructor in the
    Class Float, or the Double(String) constructor in the class Double.

    How can I arrange for different applets on a web page to communicate with each other?
    Ans : Name your applets inside the Applet tag and invoke AppletContext’s getApplet()
    method in your applet code to obtain references to the other applets on the page.

    How do I select a URL from my Applet and send the browser to that page?
    Ans : Ask the applet for its applet context and invoke showDocument() on that context object.
    Eg. URL targetURL;
    String URLString
    AppletContext context = getAppletContext();
    targetUR L = new URL(URLString);
    } catch (Malformed URLException e){
    // Code for recover from the exception
    context. showDocument (targetURL);

    Can applets on different pages communicate with each other?
    Ans : No. Not Directly. The applets will exchange the information at one meeting place
    either on the local file system or at remote system.

    How do Applets differ from Applications?
    Ans : Application: Stand Alone
    Applet: Needs no explicit installation on local m/c.
    Application: Execution starts with main() method.
    Applet: Execution starts with init() method.
    Application: May or may not be a GUI
    Applet: Must run within a GUI (Using AWT)

    How do I determine the width and height of my application?
    Ans : Use the getSize() method, which the Applet class inherits from the Component
    class in the Java.awt package. The getSize() method returns the size of the applet as
    a Dimension object, from which you extract separate width, height fields.
    Eg. Dimension dim = getSize ();
    int appletwidth = dim.width ();

    What is AppletStub Interface?
    Ans : The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface.

    It is essential to have both the .java file and the .html file of an applet in the same
    Ans : b.

    The tag contains two attributes namely _________ and _______.
    Ans : Name , value.

    Passing values to parameters is done in the _________ file of an applet.
    Ans : .html.

    What tags are mandatory when creating HTML to display an applet
    name, height, width
    code, name
    codebase, height, width
    code, height, width
    Ans : d.

    Applet’s getParameter( ) method can be used to get parameter values.
    Ans : a.

    What are the Applet’s Life Cycle methods? Explain them?
    Ans : init( ) method – Can be called when an applet is first loaded.
    start( ) method – Can be called each time an applet is started.
    paint( ) method – Can be called when the applet is minimized or refreshed.
    stop( ) method – Can be called when the browser moves off the applet’s page.
    destroy( ) method – Can be called when the browser is finished with the applet.

    What are the Applet’s information methods?
    Ans : getAppletInfo( ) method : Returns a string describing the applet, its author ,copy
    right information, etc.
    getParameterInfo( ) method : Returns an array of string describing the applet’s parameters.

    All Applets are subclasses of Applet.
    Ans : a.

    All Applets must import java.applet and java.awt.
    Ans : a.

    What are the steps involved in Applet development?
    Ans : a) Edit a Java source file,
    b) Compile your program and
    c) Execute the appletviewer, specifying the name of your applet’s source file.

    Applets are executed by the console based Java run-time interpreter.
    Ans : b.

    Which classes and interfaces does Applet class consist?
    Ans : Applet class consists of a single class, the Applet class and three interfaces: AppletContext,
    AppletStub and AudioClip.

    What is the sequence for calling the methods by AWT for applets?
    Ans : When an applet begins, the AWT calls the following methods, in this sequence.
    init( )
    start( )
    paint( )

    When an applet is terminated, the following sequence of method cals takes place :
    stop( )
    destroy( )

    Which method is used to output a string to an applet?
    Ans : drawString ( ) method.

    Every color is created from an RGB value.
    Ans : a.


    How would you set the color of a graphics context called g to cyan?
    g.setColor(new Color(cyan));
    Ans : a.
    The code below draws a line. What color is the line?
    g.drawLine(0, 0, 100,100);
    Ans : d.

    What does the following code draw?
    g.drawLine(10, 10, 10, 50);
    g.drawRect(100, 100, 150, 150);
    A red vertical line that is 40 pixels long and a red square with sides of 150 pixels
    A black vertical line that is 40 pixels long and a red square with sides of 150 pixels
    A black vertical line that is 50 pixels long and a red square with sides of 150 pixels
    A red vertical line that is 50 pixels long and a red square with sides of 150 pixels
    A black vertical line that is 40 pixels long and a red square with sides of 100 pixel
    Ans : b.

    Which of the statements below are true?
    A polyline is always filled.
    b) A polyline can not be filled.
    c) A polygon is always filled.
    d) A polygon is always closed
    e) A polygon may be filled or not filled
    Ans : b, d and e.

    What code would you use to construct a 24-point bold serif font?
    new Font(Font.SERIF, 24,Font.BOLD);
    new Font(“SERIF”, 24, BOLD”);
    new Font(“BOLD “, 24,Font.SERIF);
    new Font(“SERIF”, Font.BOLD,24);
    new Font(Font.SERIF, “BOLD”, 24);
    Ans : d.

    Don't miss out!
    Subscribe To Newsletter

    Receive top technical news, lesson ideas, travel tips and more!

    Invalid email address
    Give it a try. You can unsubscribe at any time.

    Spread the love
    • 1


    Please enter your comment!
    Please enter your name here