OCJP Certification Sample Question Set-6

    Spread the love
    • 1

    OCJP Certification Sample Question Set-6
    OCJP Certification Sample Question Set-6

    OCJP Certification Sample Question Set-6:

    Thread and Multi Tasking related:

    1) What are the two types of multitasking?
    Ans : 1.process-based
    2) What are the two ways to create the thread?
    Ans : 1.by implementing Runnable
    2.by extending Thread
    3) What is the signature of the constructor of a thread class?
    Ans : Thread(Runnable threadob,String threadName)
    4) What are all the methods available in the Runnable Interface?
    Ans : run()
    5) What is the data type for the method isAlive() and this method is
    available in which class?
    Ans : boolean, Thread
    6) What are all the methods available in the Thread class?
    Ans : 1.isAlive()
    7) What are all the methods used for Inter Thread communication and what is the class in which these methods are defined?
    Ans :1. wait(),notify() & notifyall()
    2. Object class
    8) What is the mechanisam defind by java for the Resources to be used by only one Thread at a time?
    Ans : Synchronisation
    9) What is the procedure to own the moniter by many threads?
    Ans : not possible
    10) What is the unit for 1000 in the below statement?
    Ans : long milliseconds
    11) What is the data type for the parameter of the sleep() method?
    Ans : long
    12) What are all the values for the following level?
    Ans : 10,1,5
    13) What is the method available for setting the priority?
    Ans : setPriority()
    14) What is the default thread at the time of starting the program?
    Ans : main thread
    15) The word synchronized can be used with only a method.
    True/ False
    Ans : False
    16) Which priority Thread can prompt the lower primary Thread?
    Ans : Higher Priority
    17) How many threads at a time can access a monitor?
    Ans : one
    18) What are all the four states associated in the thread?
    Ans : 1. new 2. runnable 3. blocked 4. dead
    19) The suspend()method is used to teriminate a thread?
    True /False
    Ans : False
    20) The run() method should necessary exists in clases created as subclass of thread?
    True /False
    Ans : True
    21) When two threads are waiting on each other and can’t proceed the programe is said to be in a deadlock?
    Ans : True
    22) Which method waits for the thread to die ?
    Ans : join() method
    23) Which of the following is true?
    1) wait(),notify(),notifyall() are defined as final & can be called only from with in a synchronized method
    2) Among wait(),notify(),notifyall() the wait() method only throws IOException
    3) wait(),notify(),notifyall() & sleep() are methods of object class
    1 & 2
    1,2 & 3
    Ans : D
    24) Garbage collector thread belongs to which priority?
    Ans : low-priority
    25) What is meant by timeslicing or time sharing?
    Ans : Timeslicing is the method of allocating CPU time to individual threads in a priority schedule.
    26) What is meant by daemon thread? In java runtime, what is it’s role?
    Ans : Daemon thread is a low priority thread which runs intermittently in the background doing the garbage collection operation for the java runtime system.

    Inheritance Related:

    1) What is the difference between superclass & subclass?
    Ans : A super class is a class that is inherited whereas subclass is a class that does the inheriting.
    2) Which keyword is used to inherit a class?
    Ans : extends
    3) Subclasses methods can access superclass members/ attributes at all times?
    Ans : False
    4) When can subclasses not access superclass members?
    Ans : When superclass is declared as private.
    5) Which class does begin Java class hierarchy?
    Ans : Object class
    6) Object class is a superclass of all other classes?
    Ans : True
    7) Java supports multiple inheritance?
    Ans : False
    8) What is inheritance?
    Ans : Deriving an object from an existing class. In the other words, Inheritance is the process of inheriting all the features from a class
    9) What are the advantages of inheritance?
    Ans : Reusability of code and accessibility of variables and methods of the superclass by subclasses.
    10) Which method is used to call the constructors of the superclass from the subclass?
    Ans : super(argument)
    11) Which is used to execute any method of the superclass from the subclass?
    Ans : super.method-name(arguments)
    12) Which methods are used to destroy the objects created by the constructor methods?
    Ans : finalize()
    13) What are abstract classes?
    Ans : Abstract classes are those for which instances can’t be created.
    14) What must a class do to implement an interface?
    Ans: It must provide all of the methods in the interface and identify the interface in its implements clause.
    15) Which methods in the Object class are declared as final?
    Ans : getClass(), notify(), notifyAll(), and wait()
    16) Final methods can be overridden.
    Ans : False
    17) Declaration of methods as final results in faster execution of the program?
    Ans: True
    18) Final variables should be declared in the beginning?
    Ans : True
    19) Can we declare variable inside a method as final variables? Why?
    Ans : Cannot because, local variable cannot be declared as final variables.
    20) Can an abstract class may be final?
    Ans : An abstract class may not be declared as final.
    21) Does a class inherit the constructors of it’s super class?
    Ans: A class does not inherit constructors from any of it’s super classes.
    22) What restrictions are placed on method overloading?
    Ans: Two methods may not have the same name and argument list but different return types.
    23) What restrictions are placed on method overriding?
    Ans : Overridden methods must have the same name , argument list , and return type. The overriding method may not limit the access of the method it overridees.The overriding method may not throw any exceptions that may not be thrown by the overridden method.
    24) What modifiers may be used with an inner class that is a member of an outer class?
    Ans : a (non-local) inner class may be declared as public, protected, private, static, final or abstract.
    25) How this() is used with constructors?
    Ans: this() is used to invoke a constructor of the same class
    26) How super() used with constructors?
    Ans : super() is used to invoke a super class constructor
    27) Which of the following statements correctly describes an interface?
    a)It’s a concrete class
    b)It’s a superclass
    c)It’s a type of abstract class
    Ans: c
    28) An interface contains __ methods
    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