Java Certification Exam

1. Valid modifiers :

2. Range of int & char

3. Valid top level class declarations

Class A { }

Class A extends B,C{ }

Class A extends B{ }

Import java.awt.*;

Public Class A { }

4. Given a class declaration, what are the valid statements that can be inserted before the class definition


class A{


Import java.awt.*;

Package awt;

Class B { }

Static int I=10;

5. Given a class One in which a public void method( ){ } is defined, what are the valid method definitions that can be included in a sub class of A without changing the class definitions.

Class One{

Public void method( ){ }


Class Two extends One{

Public void meth1( ){ }



void othermethod( ){…}

int method( ){….}

int method(String s){ ….}

void method( ){ }

public int othermethod (String s ){ }

6. Octal representation of an integer.

7. What is the value of x that can print "test2".

If else construct, if(x>4)


Else if(x>9)





8. Garbage collection:

(i)Programmer can explicitly indicate that the memory space allocated to an object reference variable is no longer used & can be freed

(ii) the time when the memory is freed by garbage collection is not predictable

9. Threads: What causes a thread to stop :

  1. The thread execute wait( )
  2. A thread of higher priority gets into Runnable state.
  3. An interrupted Exception is thrown
  4. A thread requests for getID

10. Threads:

(i) The JVM exits as soon as the main method exits.

(ii)Inconsistency of data arises when multiple threads access the same object without a lock.

11. Keyword used to work with multiple threads accessing the same object using object locks: synchronized

12. The argument that is passed into all the methods of mouse listeners. MouseEvent

13. The return value of all listener methods in Delegation Event Model Void

14. GridBagLayout:

  1. weightx & weighty values range from 0.0 to 1.0
  2. relationship between anchor & fill
  3. only one row or column is modified when the window is resized

15. Height of the component varies with window resizing but width remains constant (East & West of Border Layout)

16. The component size should always be retained irrespective of the resizing of container. Flow Layout

17. What happens when the button ("click me" ) is pressed.

Class panel1 extends Panel{

String s;

Button b=new Button("Click me");


b.addActionListener(new ActionListener(

public void actionPerformed(ActionEvent ae){

s= "message";

System.out.println("message is "+s);




18. Return type of main method Void

19. The util interface that is used to group objects with ordering allowing duplicates : List

20. Reading one line of data at a time from a socket connected to the network with an input stream object s. The output to be in standard ASCII character encoding.

BufferedReader b= new

BufferedReader (new InputStreamReader(s.getInputStreamReader), "8859_1");

21. An application consists of a set of user interfaces & the various operations are to be performed based on the various user invoked events. Which of the following are true for the above application

  1. Extending Adapter classes is not suitable
  2. Some listener interface must be implemented
  3. If a particular event listener is implemented only the methods of interest to us need to be implemented
  4. Multiple event listeners can be added to a single component
  5. The order in which the events are processed is the order in which the listeners are added

22. What code can be inserted at /////A so that it fully implements the existing code to initialise the values of x & str.

class A {

String str;

Int x;

Int z;

public A(String s , int a){

str = s ;

x = a ;


public A(int a,String s){



class B extends A{

public B(String s, int a){



public B(String s, int a, int c) {


z = c;



23. What is the earliest point where the memory space allocated to the string in line 2(s1) can be released.

class Str {

String s= "Hello" ;

String s1= " there";

Public static void main(String[] args){


System.out.println(s+ " my friend"); } }

class A{

String s1="Hi";

String s2="There";

public static void main(String[] args){







  1. Two String Buffers are given & the result of the assignment of one reference to the other is tested using the .equals( ) method.
  2. Valid array declarations for a two dimensional array

Int arr[][] = new int[10][10]

Int [][] arr = new int[10][10]

Int[]arr[] = new int[10][10]

26. Which of the following statements throws a null pointer exception

given String s=null;





  1. An Employee is a Person & he has a name that is stored in a string ,& info that is stored in a vector…….construct the class definition

Public class Employee extends Person

28. Similar question select the datatypes used

Vector, String……

29. if meth1( ) can throw a Protocol Exception which is not a subclass of Runtime Exception, what are the types of exceptions that can be declared to be thrown by the method definition of meth( )

class A{

int a;

meth( ){

meth1( ){ }




Protocol Exception