Question 31:  

From: Kohli, Hardeep (12 Feb 2000) / 1.x
Choose the correct statement about gridbag layout:

A.
  The weightx & weighty should have values between 0.0 & 1.0
B.
  If you specify the fill field is BOTH, there is no meaning to set anchor field
C.
  If you specify anchor field there is no meaning to set fill field is BOTH

Question 32:  

From: Kohli, Hardeep (12 Feb 2000) / 1.x
What is the return type of main function which is the starting point of class

   

Question 33: Language

From: Kohli, Hardeep (12 Feb 2000) / 1.x
Employee is a person. Employee has some info stored in vector, no of dependants, a flag tells is he IT asesse or not.
public
Person
Employee
Vector
Boolean
int
class
extends
                     
Write a primary declaration for employee class by using the below words:

   

Question 34: Declarations

From: Kohli, Hardeep (12 Feb 2000) / 1.1.x
If you want to make your component to activate for user events, chose the statements which are correct

A.
  you can add listener interfaces to this component.
B.
  if you add multiple listeners they fill become friendly to eachother.
C.
  you can add multiple interfaces to the component for different events.
D.
  if listeners added, user can choose and implement only those methods what he needs
E.
  the component which is derived from awt component is not listening to the events for itself.

Question 35: Language

From: Kohli, Hardeep (12 Feb 2000) / 1.x
Choose the correct one about thread:

A.
  The threads from one class ends at the same time.
B.
  when JVM exists the main method, it will stop only after all the threads are stopped.
C.
  if there are multiple threads, reading or writing of data of class is inconsitent.
D.
  programmer has to write a special program for garbagecollection in multiple threads.

Question 36: Declarations

From: Kohli, Hardeep (12 Feb 2000) / 1.0.x
FilterInputStream is base class for BufferedInputStream and DataInputStream. Chose the correct one which is the correct argument for the FilterInputStream?

A.
  File
B.
  OutputStream
C.
  RandomAccessFile
D.
  InputStream

Question 37:  

From: Kohli, Hardeep (12 Feb 2000) / 1.x
String s = "Test"; Select all correct answers:
1. char c = "s";
2. s= s.append("For ")
3. s.length();
4. s.trim();
5.s = "For " + s;
                     

A.
  1
B.
  2
C.
  3
D.
  4
E.
  5

Question 38:  

From: Kohli, Hardeep (12 Feb 2000) / 1.x
All the methods in Listener Interfaces should be?

A.
  private
B.
  public
C.
  protected
D.
  undefined (friendly)
E.
  static
F.
  final

Question 39: Language

From: Kohli, Hardeep (12 Feb 2000) / 1.x
>> and >>> are?
                     

A.
  unsigned tright shift and right rotate
B.
  unsigned right shift and signed right shift
C.
  signed right shift and unsigned right shift
D.
  signed left shift and unsigned right shift
E.
  signed left shift and unsigned left shift

Question 40:  

From: Kohli, Hardeep (12 Feb 2000) / 1.1.x
import java.awt.*;
import java.awt.event.*;
public class fram extends Frame {
	public static void main(String arg[]) {
		fram f = new fram();
		String msg = "hello";
		Button b = new Button("Click");
		b.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.out.println(msg);
			}
		});
		f.add(b);
		f.pack();
		f.show();
	}
}
                     
Which of the following statements is true about the above code?

A.
  The code will not compile complaining that no layout has been defined for the frame.
B.
  The code compiles and doesn't display anything.
C.
  The code runs and shows a single button occupying the whole frame. On clicking the button you get the message "hello" at the Std o/p.
D.
  The code does not compile complaining about the inaccessibility of a certain variable.
E.
  The code doesn't compile complaining that the constructor for fram has not been defined.

Question 41: Runtime errors

From: Kohli, Hardeep (12 Feb 2000) / 1.x
class exSuper {
	public void func(String p, String s) {
		System.out.println(p);
	}
}
public class example extends exSuper {
	public void func(String p, String s) {
		System.out.println(p + " : " + s);
	}
	static public void main(String arg[]) {
		exSuper e1 = new exSuper();
		e1.func("hello1", "hi1");
		exSuper e2 = new example();
		e2.func("hello2", "hi2");
	}
}
                     
Which of the following is true?

A.
  The code compiles and prduces output to stdout: hello1 h1 hello2 hi2
B.
  The code compiles and prduces output to stdout: hello1 hello2: hi2
C.
  The code compiles and prduces output to stdout: hello1 hello2
D.
  The code compiles and prduces output to stdout: hello1 h1 hello2
E.
  The code doesn't compile

Question 42: Language

From: Kohli, Hardeep (12 Feb 2000) / 1.x
Which of the following statements is valid?

A.
  The JVM runs till the main method exits, even if there are other user threads running.
B.
  An InterruptedException occurs when the sleep() method is called on a thread.
C.
  A thread can be suspended for an indefinite duration of time.
D.
  A thread can be made in Java only by subclassing the Thread class.
E.
  The synchronize keyword can be used only in a method that is part of a class that is derived from Thread

Question 43:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Which statement are characteristics of the >> and >>> operators.

A.
  >> performs a shift
B.
  >> performs a rotate
C.
  >> performs a signed and >>> performs an unsigned shift
D.
  >> performs an unsigned and >>> performs a signed shift
E.
  >> should be used on integrals and >>> should be used on floating point types

Question 44:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Given the following declaration
String s = "Example";
                     
Which are legal code?

A.
  s >>> = 3;
B.
  s[3] = "x";
C.
  int i = s.length();
D.
  String t = "For " + s;
E.
  s = s + 10;

Question 45:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Which statements are true about listeners?

A.
  The return value from a listener is of boolean type.
B.
  Most components allow multiple listeners to be added.
C.
  A copy of the original event is passed into a listener method.
D.
  If multiple listeners are added to a single component, they all must all be friends to each other.
E.
  If the multiple listeners are added to a single component, the order [in which listeners are called is guaranteed].

Question 46:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
What might cause the current thread to stop executing.

A.
  An InterruptedException is thrown.
B.
  The thread executes a wait() call.
C.
  The thread constructs a new Thread.
D.
  A thread of higher priority becomes ready.
E.
  The thread executes a waitforID() call on a MediaTracker.

Question 47:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Given the following incomplete method.
1. public void method(){
2.
3. if (someTestFails()){
4. 
5. }
6. 
7.}
                     
You want to make this method throw an IOException if, and only if, the method someTestFails() returns a value of true. Which changes achieve this?

A.
  Add at line 2: IOException e;
B.
  Add at line 4: throw e;
C.
  Add at line 4: throw new IOException();
D.
  Add at line 6: throw new IOException();
E.
  Modify the method declaration to indicate that an object of [type] Exception might be thrown.

Question 48:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Which modifier should be applied to a method for the lock of the object this to be obtained prior to executing any of the method body?

A.
  final
B.
  static
C.
  abstract
D.
  protected
E.
  synchronized

Question 49:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Which are keywords in Java?

A.
  NULL
B.
  true
C.
  sizeof
D.
  implements
E.
  instanceof

Question 50:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Consider the following code:
Integer s = new Integer(9);
Integer t = new Integer(9);
Long u = new Long(9);
                     
Which test would return true?

A.
  (s==u)
B.
  (s==t)
C.
  (s.equals(t))
D.
  (s.equals(9))
E.
  (s.equals(new Integer(9)))

Question 51:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Why would a responsible Java programmer want to use a nested class?

A.
  To keep the code for a very specialized class in close association with the class it works with.
B.
  To support a new user interface that generates custom events.
C.
  To impress the boss with his/her knowledge of Java by using nested classes all over the place.

Question 52:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
You have the following code. Which numbers will cause "Test2" to be printed?
switch (x) {
	case 1 :
		System.out.println("Test1");
	case 2 :
	case 3 :
		System.out.println("Test2");
		break;
}
System.out.println("Test3");
}
                     

A.
  0
B.
  1
C.
  2
D.
  3
E.
  4

Question 53:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Which statement declares a variable a which is suitable for referring to an array of 50 string objects?

A.
  char a[][];
B.
  String a[];
C.
  String []a;
D.
  Object a[50];
E.
  String a[50];
F.
  Object a[];

Question 54:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
What should you use to position a Button within an application frame so that the width of the Button is affected by the Frame size but the height is not affected.

A.
  FlowLayout
B.
  GridLayout
C.
  Center area of a BorderLayout
D.
  East or West of a BorderLayout
E.
  North or South of a BorderLayout

Question 55:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
What might cause the current thread to stop executing?

A.
  An InterruptedException is thrown
B.
  The thread executes a sleep() call
C.
  The thread constructs a new Thread
D.
  A thread of higher priority becomes ready (runnable)
E.
  The thread executes a read() call on an InputStream

Question 56:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Consider the following code:
String s = null;
                     
Which code fragments cause an object of type NullPointerException to be thrown?

A.
  if((s!=null) & (s.length()>0))
B.
  if((s!=null) &&(s.length()>0))
C.
  if((s==null) | (s.length()==0))
D.
  if((s==null) || (s.length()==0))

Question 57:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Consider the following code:
String s = null;
                     
Which code fragments cause an object of type NullPointerException to be thrown?

A.
  if((s==null) & (s.length()>0))
B.
  if((s==null) &&(s.length()>0))
C.
  if((s!=null) | (s.length()==0))
D.
  if((s!=null) || (s.length()==0))

Question 58:  

From: Thomas Bengtsson (24 Feb 2000) / 1.1.x
Which statement is true about an inner class?

A.
  It must be anonymous
B.
  It can not implement an interface
C.
  It is only accessible in the enclosing class
D.
  It can only be instantiated in the enclosing class
E.
  It can access any final variables in any enclosing scope.

Question 59:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Which statements are true about threads?

A.
  Threads created from the same class all finish together
B.
  A thread can be created only by subclassing Java.Lang.Thread.
C.
  Invoking the suspend() stops a thread so that it cannot be restarted
D.
  The Java Interpreter's natural exit occurs when no non daemon threads
E.
  Uncoordinated changes to shared data by multiple threads may result in the data being read, or left, in an inconsistent state.

Question 60:  

From: Thomas Bengtsson (24 Feb 2000) / 1.x
Consider the following code:
1. public void method(String s){
2.    String a,b;
3.      a = new String("Hello");
4.      b = new String("Goodbye");
5.      System.out.println(a + b);
6.      a = null;
7.      a = b;  
8.      System.out.println(a + b);
9. }
                     
Where is it possible that the garbage collector will run the first time?

A.
  Just before line 5
B.
  Just before line 6
C.
  Just before line 7
D.
  Just before line 8
E.
  Never in this method

{loading}{scripting-1}{scripting}

The Notes
Part I
Part II
Part III
Part IV
Answers{submenus}
DISCLAIMER
   
 

 

1