Make your own free website on Tripod.com

Questions on Language Fundamentals

  1. Which of these are legal identifiers. Select all the correct answers.
    1. number_1
    2. number_a
    3. $1234
    4. -volatile
  2. Which of these are not legal identifiers. Select all the correct answers.
    1. 1alpha
    2. _abcd
    3. xy+abc
    4. transient
    5. account-num
    6. very_long_name
  3. Which of the following are keywords in Java. Select all the correct answers.
    1. friend
    2. NULL
    3. implement
    4. synchronized
    5. throws
  4. Which of the following are Java keywords. Select all the correct answers.
    1. super
    2. strictfp
    3. void
    4. synchronize
    5. instanceof
  5. Which of these are Java keywords. Select all the correct answers
    1. TRUE
    2. volatile
    3. transient
    4. native
    5. interface
    6. then
    7. new
  6. Using up to four characters, write the Java representation of octal literal 6.
  7. Using up to four characters, write the Java representation of integer literal 3 in hexadecimal.
  8. Using up to four characters, write the Java representation of integer literal 10 in hexadecimal.
  9. What is the minimum value of char type. Select the one correct answer.
    1. 0
    2. -215
    3. -28
    4. -215 - 1
    5. -216
    6. -216 - 1
  10. How many bytes are used to represent the primitive data type int in Java. Select the one correct answer.
    1. 2
    2. 4
    3. 8
    4. 1
    5. The number of bytes to represent an int is compiler dependent.
  11. What is the legal range of values for a variable declared as a byte. Select the one correct answer.
    1. 0 to 256
    2. 0 to 255
    3. -128 to 127
    4. -128 to 128
    5. -127 to 128
    6. -215 to 215 - 1
  12. The width in bits of double primitive type in Java is --. Select the one correct answer.
    1. The width of double is platform dependent
    2. 64
    3. 128
    4. 8
    5. 4
  13. What would happen when the following is compiled and executed. Select the one correct answer.
    
    public class Compare { 
    	public static void main(String args[]) {
    		int x = 10, y;
    		if(x < 10) 
    			y = 1;
    		if(x>= 10) y = 2;
    		System.out.println("y is " + y);
    	}
    }
    
    
    1. The program compiles and prints y is 0 when executed.
    2. The program compiles and prints y is 1 when executed.
    3. The program compiles and prints y is 2 when executed.
    4. The program does not compile complaining about y not being initialized.
    5. The program throws a runtime exception.
  14. What would happen when the following is compiled and executed. Select the one correct answer.
    
    class example {
    	int x;
    	int y;
    	String name;
    	public static void main(String args[]) {
    		example pnt = new example();
    		System.out.println("pnt is " + pnt.name + 
    			" " + pnt.x + " " + pnt.y);		
    	}
    }
    
    
    1. The program does not compile because x, y and name are not initialized.
    2. The program throws a runtime exception as x, y, and name are used before initialization.
    3. The program prints pnt is 0 0.
    4. The program prints pnt is null 0 0.
    5. The program prints pnt is NULL false false
  15. The initial value of an instance variable of type String which is not explicitly initialized in the program is --. Select the one correct answer.
    1. null
    2. ""
    3. NULL
    4. 0
    5. The instance variable must be explicitly assigned.
  16. The initial value of a local variable of type String which is not explicitly initialized and which is defined in a member function of a class. Select all the correct answer.
    1. null
    2. ""
    3. NULL
    4. 0
    5. The local variable must be explicitly assigned.
  17. Which of the following are legal Java programs. Select all the correct answer.
    1. // The comments come before the package
      package pkg;
      import java.awt.*;
      class C{};
    2. package pkg;
      import java.awt.*;
      class C{};
    3. package pkg1;
      package pkg2;
      import java.awt.*;
      class C{};
    4. package pkg;
      import java.awt.*;
    5. import java.awt.*;
      class C{};
    6. import java.awt.*;
      package pkg;
      class C {};
  18. Which of the following statements are correct. Select all correct answers.
    1. A Java program must have a package statement.
    2. A package statement if present must be the first statement of the program
    3. If a Java program defines both a package and import statement, then the import statement must come before the package statement.
    4. An empty file is a valid source file.
    5. A Java file without any class or interface definitions can also be compiled.
    6. If an import statement is present, it must appear before any class or interface definitions.
  19. What would be the results of compiling and running the following class. Select the one correct answer.
    
    class test {
    	public static void main() {
    		System.out.println("test");
    	}
    }
    
    
    1. The program does not compile as there is no main method defined.
    2. The program compiles and runs generating an output of "test"
    3. The program compiles and runs but does not generate any output.
    4. The program compiles but does not run.
  20. Which of these are valid declarations for the main method? Select all correct answers.
    1. public void main();
    2. static void main(String args[]);
    3. public static void main(String args[]);
    4. static public void main(String);
    5. public static void main(String );
    6. public static int main(String args[]);
  21. Which of the following are valid declarations for the main method. Select all correct answers.
    1. public static void main(String args[]);
    2. public static void main(String []args);
    3. final static public void main (String args[]);
    4. public static int main(String args[]);
    5. public static abstract void main(String args[]);
  22. What happens when the following program is compiled and executed with the arguments - java test. Select the one correct answer.
    
    class test {
    	public static void main(String args[]) {
    		if(args.length > 0)
    			System.out.println(args.length);
    	}
    }
    
    
    1. The program compiles and runs but does not print anything.
    2. The program compiles and runs and prints 0
    3. The program compiles and runs and prints 1
    4. The program compiles and runs and prints 2
    5. The program does not compile.
  23. What is the result of compiling and running this program ? Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		int i, j;
    		int k = 0;
    		j = 2;
    		k = j = i = 1;
    		System.out.println(k);		
    	}
    }
    
    
    1. The program does not compile as k is being read without being initialized.
    2. The program does not compile because of the statement k = j = i = 1;
    3. The program compiles and runs printing 0.
    4. The program compiles and runs printing 1.
    5. The program compiles and runs printing 2.
  24. What gets printed on the standard output when the class below is compiled and executed by entering "java test lets see what happens". Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		System.out.println(args[0] + " " + args[args.length - 1]);
    	}
    }
    
    
    1. The program will throw an ArrayIndexOutOfBounds exception.
    2. The program will print "java test"
    3. The program will print "java hapens";
    4. The program will print "test happens"
    5. The program will print "lets happens"
  25. What gets printed on the standard output when the class below is compiled and executed by entering "java test lets see what happens". Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		System.out.println(args[0] + " " + args[args.length]);
    	}
    }
    
    
    1. The program will throw an ArrayIndexOutOfBounds exception.
    2. The program will print "java test"
    3. The program will print "java hapens";
    4. The program will print "test happens"
    5. The program will print "lets happens"
  26. What all gets printed on the standard output when the class below is compiled and executed by entering "java test lets see what happens". Select all correct answers.
    
    public class test {
    	public static void main(String args[]) {
    		System.out.println(args[0] + " " + args.length);
    	}
    }
    
    
    1. java
    2. test
    3. lets
    4. 3
    5. 4
    6. 5
    7. 6
  27. What happens when the following program is compiled and run. Select the one correct answer.
    
    public class example {
    	int i = 0;
    	public static void main(String args[]) {
    		int i = 1;
    		i = change_i(i);
    		System.out.println(i);
    	}
    	public static int change_i(int i) {
    		i = 2;
    		i *= 2;
    		return i;
    	}
    }
    
    
    1. The program does not compile.
    2. The program prints 0.
    3. The program prints 1.
    4. The program prints 2.
    5. The program prints 4.
  28. What happens when the following program is compiled and run. Select the one correct answer.
    
    public class example {
    	int i = 0;
    	public static void main(String args[]) {
    		int i = 1;
    		change_i(i);
    		System.out.println(i);
    	}
    	public static void change_i(int i) {
    		i = 2;
    		i *= 2;
     	}
    }
    
    
    1. The program does not compile.
    2. The program prints 0.
    3. The program prints 1.
    4. The program prints 2.
    5. The program prints 4.
  29. What happens when the following program is compiled and run. Select the one correct answer.
    
    public class example {
    	int i[] = {0};
    	public static void main(String args[]) {
    		int i[] = {1};
    		change_i(i);
    		System.out.println(i[0]);
    	}
    	public static void change_i(int i[]) {
    		i[0] = 2;
    		i[0] *= 2;
     	}
    }
    
    
    1. The program does not compile.
    2. The program prints 0.
    3. The program prints 1.
    4. The program prints 2.
    5. The program prints 4.
  30. What happens when the following program is compiled and run. Select the one correct answer.
    
    public class example {
    	int i[] = {0};
    	public static void main(String args[]) {
    		int i[] = {1};
    		change_i(i);
    		System.out.println(i[0]);
    	}
    	public static void change_i(int i[]) {
    		int j[] = {2};
    		i = j;
     	}
    }
    
    
    1. The program does not compile.
    2. The program prints 0.
    3. The program prints 1.
    4. The program prints 2.
    5. The program prints 4.


    Answers to questions on Language Fundamentals
    1. a, b, c
    2. a, c, d, e
    3. d, e
    4. a, b, c, e
    5. b, c, d, e, g
    6. Any of the following are correct answers - 06, 006, or 0006
    7. Any of the following are correct answers - 0x03, 0X03, 0X3 or 0x3
    8. Any of the following are correct answers - 0x0a, 0X0a, 0Xa, 0xa, 0x0A, 0X0A, 0XA, 0xA
    9. a
    10. b
    11. c
    12. b
    13. d. The variable y is getting read before being properly initialized.
    14. d. Instance variable of type int and String are initialized to 0 and NULL respectively.
    15. a
    16. e
    17. a, b, d, e
    18. b, d, e, f
    19. d
    20. b, c
    21. a, b, c
    22. a
    23. d
    24. e
    25. a
    26. c, e
    27. e
    28. c
    29. e
    30. c

Questions on Operator and Assignments

  1. In the following class definition, which is the first line (if any) that causes a compilation error. Select the one correct answer.
    
    pubic class test {
    	public static void main(String args[]) {
    		char c;
    		int i;
    		c = 'A';		// 1
    		i = c;		//2
    		c = i + 1;	//3
    		c++;		//4
    	}
    }
    
    
    1. The line labeled 1.
    2. The line labeled 2.
    3. The line labeled 3.
    4. The line labeled 4.
    5. All the lines are correct and the program compiles.
  2. Which of these assignments are valid. Select all correct answers.
    1. short s = 28;
    2. float f = 2.3;
    3. double d = 2.3;
    4. int I = '1';
    5. byte b = 12;
  3. What gets printed when the following program is compiled and run. Select the one correct answer.
    
    class test {
    	public static void main(String args[]) {
    		int i,j,k,l=0;
    		k = l++;
    		j = ++k;
    		i = j++;
    		System.out.println(i);		
    	}
    }
    
    
    1. 0
    2. 1
    3. 2
    4. 3
  4. Which of these lines will compile? Select all correct answers.
    1. short s = 20;
    2. byte b = 128;
    3. char c = 32;
    4. double d = 1.4;;
    5. float f = 1.4;
    6. byte e = 0;
  5. The signed right shift operator in Java is --. Select the one correct answer.
    1. <<;
    2. >>
    3. >>>;
    4. None of these.
  6. What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.
    
    public static ShortCkt {
    	public static void main(String args[]) {
    		int i = 0;
    		boolean t = true;
    		boolean f = false, b;
    		b = (t && ((i++) == 0));
    		b = (f && ((i+=2) > 0));
    		System.out.println(i);		
    	}
    }
    
    
    1. 0
    2. 1
    3. 2
    4. 3
  7. What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.
    
    public static ShortCkt {
    	public static void main(String args[]) {
    		int i = 0;
    		boolean t = true;
    		boolean f = false, b;
    		b = (t & ((i++) == 0));
    		b = (f & ((i+=2) > 0));
    		System.out.println(i);		
    	}
    }
    
    
    1. 0
    2. 1
    3. 2
    4. 3
  8. What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.
    
    public static ShortCkt {
    	public static void main(String args[]) {
    		int i = 0;
    		boolean t = true;
    		boolean f = false, b;
    		b = (t || ((i++) == 0));
    		b = (f || ((i+=2) > 0));
    		System.out.println(i);		
    	}
    }
    
    
    1. 0
    2. 1
    3. 2
    4. 3
  9. What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.
    
    public static ShortCkt {
    	public static void main(String args[]) {
    		int i = 0;
    		boolean t = true;
    		boolean f = false, b;
    		b = (t | ((i++) == 0));
    		b = (f | ((i+=2) > 0));
    		System.out.println(i);		
    	}
    }
    
    
    1. 0
    2. 1
    3. 2
    4. 3
  10. Which operator is used to perform bitiwse inversion in Java. Select the one correct answer.
    1. ~
    2. !
    3. &
    4. |
    5. ^
  11. What gets printed when the following program is compiled and run. Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		byte x = 3;
    		x = (byte)~x;
    		System.out.println(x);
    	}
    }
    
    
    1. 3
    2. 0
    3. 1
    4. 11
    5. 252
    6. 214
    7. 124
    8. -4
  12. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		int x,y;
    		x = 3 & 5;
    		y = 3 | 5;
    		System.out.println(x + " " + y);
    	}
    }
    
    
    1. 7 1
    2. 3 7
    3. 1 7
    4. 3 1
    5. 1 3
    6. 7 3
    7. 7 5
  13. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		int x,y;
    		x = 1 & 7;
    		y = 3 ^ 6;
    		System.out.println(x + " " + y);
    	}
    }
    
    
    1. 1 3
    2. 3 5
    3. 5 1
    4. 3 6
    5. 1 7
    6. 1 5
  14. Which operator is used to perform bitwise exclusive or.
    1. &
    2. ^
    3. |
    4. !
    5. ~
  15. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		boolean x = true;
    		int a;
    		if(x) a = x ? 1: 2;
    		else a = x ? 3: 4;
    		System.out.println(a);
    	}
    }
    
    
    1. 1
    2. 2
    3. 3
    4. 4
  16. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		boolean x = false;
    		int a;
    		if(x) a = x ? 1: 2;
    		else a = x ? 3: 4;
    		System.out.println(a);
    	}
    }
    
    
    1. 1
    2. 2
    3. 3
    4. 4
  17. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		int x, y;
    		x = 5 >> 2;
    		y = x >>> 2;
     		System.out.println(y);
    	}
    }
    
    
    1. 5
    2. 2
    3. 80
    4. 0
    5. 64
  18. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		int x;
    		x = -3 >> 1;
    		x = x >>> 2;
    		x = x << 1;
     		System.out.println(x);
    	}
    }
    
    
    1. 1
    2. 0
    3. 7
    4. 5
    5. 23
    6. 2147483646
  19. Which of the following are correct. Select all correct answers.
    1. Java provides two operators to do left shift - << and <<.
    2. >> is the zero fill right shift operator.
    3. >>> is the signed right shift operator.
    4. For positive numbers, results of p[erators >> and >>> are same.
  20. What is the result of compiling and running the following program. Select one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		int i = -1;
    		i = i >> 1;	 
     		System.out.println(i);
    	}
    }
    
    
    1. 63
    2. -1
    3. 0
    4. 1
    5. 127
    6. 128
    7. 255
  21. What all gets printed when the following gets compiled and run. Select all correct answers.
    
    public class example {
    	public static void main(String args[]) {
    		int x = 0;
    		if(x > 0) x = 1;
    		switch(x) {
    		case 1: System.out.println(1);
    		case 0: System.out.println(0);
    		case 2: System.out.println(2);
    			break;
    		case 3: System.out.println(3);
    		default: System.out.println(4);
    			break;
    		}
    	}
    }
    
    
    1. 0
    2. 1
    3. 2
    4. 3
    5. 4
  22. What happens when the following class is compiled and run. Select one correct answer.
    
    public class test {
    	public static void main(String args[]) {
    		int x = 0, y = 1, z;
    		if(x) 
    		    z = 0;
    		else
    		    z = 1;
    		if(y) 
    		    z = 2;
    		else
    		    z = 3;
    		System.out.println(z); 		
    	}
    }
    
    
    1. The program prints 0
    2. The program prints 1
    3. The program prints 2
    4. The program prints 3
    5. The program does not compile because of problems in the if statement.
  23. Which all lines are part of the output when the following code is compiled and run. Select all correct answers.
    
    public class test {
    	public static void main(String args[]) {
    	    for(int i = 0; i < 3; i++) 
    		for(int j = 3; j >= 0; j--) {
    		    if(i == j) continue;
    		    System.out.println(i + " " + j);
    		}
    	    }
     	}
    }
    
    
    1. 0 0
    2. 0 1
    3. 0 2
    4. 0 3
    5. 1 0
    6. 1 1
    7. 1 2
    8. 1 3
    9. 2 0
    10. 2 1
    11. 2 2
    12. 2 3
    13. 3 0
    14. 3 1
    15. 3 2
    16. 3 3
    17. The program does not print anything.
  24. Which all lines are part of the output when the following code is compiled and run. Select all correct answers.
    
    public class test {
    	public static void main(String args[]) {
    	    for(int i = 0; i < 3; i++) 
    		for(int j = 3; j <= 0; j--) {
    		    if(i == j) continue;
    		    System.out.println(i + " " + j);
    		}
    	    }
     	}
    }
    
    
    1. 0 0
    2. 0 1
    3. 0 2
    4. 0 3
    5. 1 0
    6. 1 1
    7. 1 2
    8. 1 3
    9. 2 0
    10. 2 1
    11. 2 2
    12. 2 3
    13. 3 0
    14. 3 1
    15. 3 2
    16. 3 3
    17. The program does not print anything.
  25. Which all lines are part of the output when the following code is compiled and run. Select all correct answers.
    
    public class test {
    	public static void main(String args[]) {
    	    for(int i = 0; i < 3; i++) 
    		for(int j = 3; j >= 0; j--) {
    		    if(i == j) break;
    		    System.out.println(i + " " + j);
    		}
    	    }
     	}
    }
    
    
    1. 0 0
    2. 0 1
    3. 0 2
    4. 0 3
    5. 1 0
    6. 1 1
    7. 1 2
    8. 1 3
    9. 2 0
    10. 2 1
    11. 2 2
    12. 2 3
    13. 3 0
    14. 3 1
    15. 3 2
    16. 3 3
  26. Which all lines are part of the output when the following code is compiled and run. Select all correct answers.
    
    public class test {
    	public static void main(String args[]) {
    outer: 	    for(int i = 0; i < 3; i++) 
    		for(int j = 3; j >= 0; j--) {
    		    if(i == j) continue outer;
    		    System.out.println(i + " " + j);
    		}
    	    }
     	}
    }
    
    
    1. 0 0
    2. 0 1
    3. 0 2
    4. 0 3
    5. 1 0
    6. 1 1
    7. 1 2
    8. 1 3
    9. 2 0
    10. 2 1
    11. 2 2
    12. 2 3
    13. 3 0
    14. 3 1
    15. 3 2
    16. 3 3
  27. Which all lines are part of the output when the following code is compiled and run. Select all correct answers.
    
    public class test {
    	public static void main(String args[]) {
    outer :	    for(int i = 0; i < 3; i++) 
    		for(int j = 3; j >= 0; j--) {
    		    if(i == j) break outer;
    		    System.out.println(i + " " + j);
    		}
    	    }
     	}
    }
    
    
    1. 0 0
    2. 0 1
    3. 0 2
    4. 0 3
    5. 1 0
    6. 1 1
    7. 1 2
    8. 1 3
    9. 2 0
    10. 2 1
    11. 2 2
    12. 2 3
    13. 3 0
    14. 3 1
    15. 3 2
    16. 3 3


    Answers to questions on Operators and Asignments
    1. c. It is not possible to assign an integer to a character in this case without a cast.
    2. a, c, d, e. 2.3 is of type double. So it cannot be assigned to a float without a cast.
    3. b
    4. a, c, d, f. If RHS (Right hand side) is an integer within the correct range of LHS (Left hand side), and if LHS is char, byte, or short, no cast is required. A decimal number is a double by default. Assigning it to float requires a cast.
    5. b
    6. b. In the second assignment to variable b, the expression (i+=2) does not get evaluated.
    7. d
    8. c
    9. d
    10. a
    11. h
    12. c
    13. f
    14. b
    15. a
    16. d
    17. d
    18. f
    19. d
    20. b
    21. a, c
    22. e. The expression in the if statement must evaluate to a boolean.
    23. b, c, d, e, g, h, i, j, l
    24. q
    25. b, c, d, g, h, l
    26. b, c, d, g, h, l
    27. b, c, d



Questions on Class Fundamentals

  1. What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
    
    protected class example {
    	public static void main(String args[]) {
    		String test = "abc";
    		test = test + test;
    		System.out.println(test);
    	}
    }
    
    
    1. The class does not compile because the top level class cannot be protected.
    2. The program prints "abc"
    3. The program prints "abcabc"
    4. The program does not compile because statement "test = test + test" is illegal.
  2. A top level class may have only the following access modifier. Select one correct answer.
    1. package
    2. friendly
    3. private
    4. protected
    5. public
  3. Write down the modifier of a method which makes the method available to all classes in the same package and to all the subclases of this class.
  4. Select the one most appropriate answer. A top level class without any modifier is accessible to -
    1. any class
    2. any class within the same package
    3. any class within the same file
    4. any subclass of this class.
  5. Is this True or False. In Java an abstract class cannot be subclassed.
  6. Is this True or False. In Java a final class must be subclassed before it can be used.
  7. Which of the following are true. Select all correct answers.
    1. A static method may be invoked before even a single instance of the class is constructed.
    2. A static method cannot access non-static methods of the class.
    3. Abstract modifier can appear before a class or a method but not before a variable.
    4. final modifier can appear before a class or a variable but not before a method.
    5. Synchronized modifier may appear before a method or a variable but not before a class.

Answers to questions on classes in Java
  1. a
  2. e
  3. protected
  4. b
  5. False
  6. False
  7. a, b, c. final modifier may appear before a method or a variable but not before a class.

Questions on Collections

  1. TreeMap class is used to implement which collection interface. Select the one correct answer.
    1. Set
    2. SortedSet
    3. List
    4. Map
    5. SortedMap
  2. Name the Collection interface implemented by the Vector class.
  3. Name the Collection interface implemented by the HashTable class.
  4. Name the Collection interface implemented by the HashSet class.
  5. Which of these are interfaces in the collection framework. Select all correct answers.
    1. Set
    2. List
    3. Array
    4. Vector
    5. LinkedList
  6. Which of these are interfaces in the collection framework. Select all correct answers.
    1. HashMap
    2. ArrayList
    3. Collection
    4. SortedMap
    5. TreeMap
  7. What is the name of collection interface used to maintain non-unique elements in order.
  8. What is the name of collection interface used to maintain unique elements.
  9. What is the name of collection interface used to maintain mappings pf keys to values.
  10. Is this true or false. Map interface is derived from the Collection interface.
    1. True
    2. False

Answers to questions on Layout Managers
  1. e
  2. List
  3. Map
  4. Set
  5. a,b
  6. c,d
  7. List
  8. Set
  9. Map
  10. b


Questions on Events

  1. Name the method defined in EventObject class that returns the Object generated from the event. Select the one correct answer.
    1. getEvent()
    2. getObject()
    3. getID()
    4. getSource()
  2. What is the return type of the method getID() defined in AWTEvent class. Select the one correct answer.
    1. int
    2. long
    3. Object
    4. Component
    5. short
  3. Name the event which gets generated when a button is clicked. Select the one correct answer.
    1. KeyEvent
    2. MouseEvent
    3. ItemEvent
    4. ActionEvent
  4. Which event is generated when the position of a scrollbar is changed. Select the one correct answer.
    1. KeyEvent
    2. MouseEvent
    3. ItemEvent
    4. ActionEvent
    5. AdjustmentEvent
  5. Which of the following Objects can generate ActionEvent. Select all correct answer.
    1. List
    2. TextArea
    3. CheckBoxMenuItem
    4. Choice
  6. Which of the following Objects can generate ItemEvent. Select all correct answer.
    1. CheckBox
    2. Button
    3. List
    4. MenuItem
  7. Which method identifies the type of an event generated. Select the one correct answer.
    1. getSource()
    2. getType()
    3. getEventType()
    4. getID()
  8. Which of the following are legal adapter classes in Java. Select all correct answers.
    1. ActionAdapter
    2. ItemAdapter
    3. TextAdapter
    4. MouseAdapter
    5. MouseMotionAdapter
  9. Name the class of the argument of method actionPerformed() defined in the ActionListner interface.
  10. Which of these listner classes have corresponding adapter classes. Select all correct answers.
    1. ContainerListner
    2. TextListner
    3. ItemListner
    4. MouseMotionListner
  11. Which of these are valid adapter classes. Select all correct answers.
    1. ActionAdapter
    2. AdjustmentAdapter
    3. KeyAdapter
    4. TextAdapter
  12. Which of these methods are defined in MouseMotionListner interface. Select all correct answers.
    1. mouseClicked()
    2. mousePressed()
    3. mouseEntered()
    4. mouseDragged()
    5. mouseMoved()
  13. What is the return type of the method getSource() defined in EventObject class. Select the one correct answer.
    1. int
    2. long
    3. Object
    4. Component
    5. short

Answers to questions on Events
  1. d
  2. a
  3. d
  4. e
  5. a
  6. a, c
  7. d
  8. d, e
  9. ActionEvent
  10. a, d
  11. c
  12. d, e
  13. c

Questions on AWT

  1. Which of the following classes are derived from the Container class. Select all correct answer.
    1. Component
    2. Panel
    3. java.applet.Applet
    4. Dialog
    5. Frame
    6. MenuComponent
  2. Which of the following classes are derived from the Component class. Select all correct answer.
    1. Container
    2. Window
    3. List
    4. MenuItem
    5. Choice
  3. Name the class used to represent a GUI application window, which is optionaly resizable and can have a title bar, an icon, and menus. Select the one correct answer.
    1. Window
    2. Panel
    3. Dialog
    4. Frame
  4. Which abstract class is the super class of all menu related classes.
  5. Which of these classes can be added to a Frame component. Select all correct answer.
    1. Menu
    2. Button
    3. PopupMenu
    4. Window
    5. List
  6. Which class can be used to represent a checkbox with a textual label that can appear in a menu. Select the one correct answer.
    1. MenuBar
    2. MenuItem
    3. CheckBoxMenuItem
    4. Menu
    5. CheckBox
  7. Which of these classes can be added to a Component using the add method defined in Container class. Select all correct answers.
    1. Button
    2. CheckBoxMenuItem
    3. Menu
    4. Canvas

Answers to questions on AWT
  1. b, c, d, e
  2. a, b, c, e
  3. d
  4. MenuComponent
  5. b, c, e
  6. c
  7. a, d


Author & Copyrights 2004: Narayanaswami Banukumar