WinAVI Video Converter
WinAVI Video Converter is a ALL-IN-ONE solution for video file converting and burning, easy to use and powerful for experts. Just one click to convert with beautiful user interface. Burning VCD/SVCD/DVD is supported. It supports almost all video file formats, including AVI, MPEG1/2/4, VCD/SVCD/DVD, DivX, XVid, ASF, WMV, RM, QuickTime MOV, Flash SWF. WinAVI Video Converter has the fastest video/audio decode/encode engine in the world, convert any media to DVD in 90 minutes with stunning video and audio quality. You can enjoy the film with your home & PC DVD Player.
Features:
- AVI to DVD
- AVI to MPEG
- AVI to VCD
- AVI to MPG
- Flash SWF conversion
- It can convert all formats to MPEG1/2, VCD, SVCD, and DVD and burn to VCD, SVCD, or DVD disc.
- It can convert all video formats to AVI/WMV/RM/ASF/Divx/Xvid
- QuickTime MOV conversion.
- Real DVD Navigator encoder included.
- DirectAC3 technology supports AC3 5.1, which is state of the art technology. It is up to 20% faster with AVI files including AC3 audio.
- Real Dolby AC3 audio encoder included.
- Burning VCD/SVCD/DVD.
- Stunning video and audio quality.
- User-friendly interface that is easy to use.
- Has the option to preview the video in real-time.
- Has the option to automatically shutdown your computer when the conversion has been completed.
Thursday, August 27, 2009
Wednesday, July 8, 2009
part - 1
1. To print the value of a variable "x" of type int, which of the following expressions can be used:
(A) System.out.println("x = " + x);
(B) System.out.println("x = " + String.valueOf(x));
(C) System.out.println("x = " + Integer.toString(x));
(D) System.out.println("x = " + (new Integer(x)).toString());
(C) and (D)
(B) and (D)
(A), (B), (C) and (D)
(B), (C) and (D)
Other than the functions in the String and Integer class, the + operator can be used directly with one String operand and other one int.
2. Examine the following class definitions to detect errors, if any.
abstract class MyPanel
1 Error. Method show() should have a return type
1 Error. Method show() is not implemented in MyDisplay
1 Error. MyDisplay does not contain any members
No errors
Class MyDisplay must implement the abstract method show(), or it must also be declared abstract.
3. Consider the following code:
class NewString extends java.lang.String
Results in error because class body is not defined
Results in error because String isabstract
Results in error because the class is not declaredpublic
Results in error because java.lang.String isfinal
Compiles successfully
java.lang.String is a final class and cannot be extended.
4. Consider the following code:
int i = 1;
switch(c)
code is illegal and therefore will not compile
output will be One
output will be One followed by Two
output will be One, followed by Two, and then followed by Three
The flow of control in switch statements goes subsequently through the case statements unless explicitly broken using the break statement. In which case, the flow transfers to the first statement after the switch block. Without any break statements, all the cases are executed.
5Are there any errors in the following class definition?
abstract class Class1
Class header definition is wrong
Method definition is wrong
Constructor needs to be defined
No errors
The method func1, which is declared as abstract cannot have a body as in the code above.
6.Which of the following expressions will produce errors upon compilation?
(A) boolean a = (boolean) 1;
(B) boolean b = (false && true);
(C) float y = 22.3;
(A), (B) & (D)
(A)
(A) & (C)
(A), (C) & (D)
Integers cannot be converted to booleans, and floats must be explicitly specified (22.3f, and not 22.3 which is a double).
7.Examine the following code snippets to identify the legal loop constructs:
(A) for (int i = 22, int j = 0; i + j > 11; i = i-3, j++)
(A)
(A) & (D)
(B)
(A) & (C)
In option (B), the argument of "while" is an integer, which is illegal. It can only be boolean. In option (C), "int i > 0" is an illegal construct.
8.Which lines of the following will produce an error?
1. byte a1 = 2, a2 = 4, a3;
2. short s = 16;
3. a2 = s;
4. a3 = a1 * a2;
(The lines are numbered only for illustration in this question.)
Line 3 and Line 4
Line 1 and Line 4
Line 4 only
Line 3 only
Line 1 only
In line 3, a short value is being assigned to a variable of type byte, which is illegal. Also, the "*" operator promotes the bytes to integers, which makes it illegal to assign the return value to a variable of type byte.
9.Determine the output when the value of x is zero:
if(x >= 0)
if(x > 0)
System.out.println("x is positive");
else
System.out.println("x is negative");
None of these
"x is negative"
"x is positive"
"x is positive" and "x is negative"
The "else" statement corresponds to the second "if" in this case. To have it correspond to the first "if", curly braces
10.The control expression in an "if" statement must be:
an expression with either the type boolean or integer
an expression with type integer
an expression with type boolean
an expression with either the type boolean or integer with value 0 or 1
In the Java programming language, only expressions of type boolean are allowed as control expressions in an "if" statement.
1) What is the value of a?
2) int a = 7;
int b = 4;
a = b;
a = a + 1;
One answer only.
4
5
7
8
________________________________________
2) What output will the following line produce? System.out.println("The answer is: "+17+3);
One answer only.
The answer is: 20
The answer is: 17+3
The answer is: 173
The answer is:
________________________________________
3) What is the value of x?
4) int x = 8 / 3;
One answer only.
1
2
2.666666667
3
________________________________________
4) What is the value of y?
int y = 19 % 4;
One answer only.
2
3
4
4.75
________________________________________
5) What is the value of z?
double z = 7 / (3 + 0.5);
One answer only.
0.5
2.0
2.833333333
3.0
Question 1:
What is the value of a?
int a = 7;
int b = 4;
a = b;
a = a + 1;
Options: Your Response: Correct Answer:
4
5
7
8
see a demonstration.
________________________________________
Question 2:
What output will the following line produce?
System.out.println("The answer is: "+17+3);
Options: Your Response: Correct Answer:
The answer is: 20
The answer is: 17+3
The answer is: 173
The answer is:
see a demonstration.
________________________________________
Question 3:
What is the value of x?
int x = 8 / 3;
Options: Your Response: Correct Answer:
1
2
2.666666667
3
see a demonstration.
________________________________________
Question 4:
What is the value of y?
int y = 19 % 4;
Options: Your Response: Correct Answer:
2
3
4
4.75
see a demonstration.
________________________________________
Question 5:
What is the value of z?
double z = 7 / (3 + 0.5);
Options: Your Response: Correct Answer:
0.5
2.0
2.833333333
3.0
see a demonstration.
(A) System.out.println("x = " + x);
(B) System.out.println("x = " + String.valueOf(x));
(C) System.out.println("x = " + Integer.toString(x));
(D) System.out.println("x = " + (new Integer(x)).toString());
(C) and (D)
(B) and (D)
(A), (B), (C) and (D)
(B), (C) and (D)
Other than the functions in the String and Integer class, the + operator can be used directly with one String operand and other one int.
2. Examine the following class definitions to detect errors, if any.
abstract class MyPanel
1 Error. Method show() should have a return type
1 Error. Method show() is not implemented in MyDisplay
1 Error. MyDisplay does not contain any members
No errors
Class MyDisplay must implement the abstract method show(), or it must also be declared abstract.
3. Consider the following code:
class NewString extends java.lang.String
Results in error because class body is not defined
Results in error because String isabstract
Results in error because the class is not declaredpublic
Results in error because java.lang.String isfinal
Compiles successfully
java.lang.String is a final class and cannot be extended.
4. Consider the following code:
int i = 1;
switch(c)
code is illegal and therefore will not compile
output will be One
output will be One followed by Two
output will be One, followed by Two, and then followed by Three
The flow of control in switch statements goes subsequently through the case statements unless explicitly broken using the break statement. In which case, the flow transfers to the first statement after the switch block. Without any break statements, all the cases are executed.
5Are there any errors in the following class definition?
abstract class Class1
Class header definition is wrong
Method definition is wrong
Constructor needs to be defined
No errors
The method func1, which is declared as abstract cannot have a body as in the code above.
6.Which of the following expressions will produce errors upon compilation?
(A) boolean a = (boolean) 1;
(B) boolean b = (false && true);
(C) float y = 22.3;
(A), (B) & (D)
(A)
(A) & (C)
(A), (C) & (D)
Integers cannot be converted to booleans, and floats must be explicitly specified (22.3f, and not 22.3 which is a double).
7.Examine the following code snippets to identify the legal loop constructs:
(A) for (int i = 22, int j = 0; i + j > 11; i = i-3, j++)
(A)
(A) & (D)
(B)
(A) & (C)
In option (B), the argument of "while" is an integer, which is illegal. It can only be boolean. In option (C), "int i > 0" is an illegal construct.
8.Which lines of the following will produce an error?
1. byte a1 = 2, a2 = 4, a3;
2. short s = 16;
3. a2 = s;
4. a3 = a1 * a2;
(The lines are numbered only for illustration in this question.)
Line 3 and Line 4
Line 1 and Line 4
Line 4 only
Line 3 only
Line 1 only
In line 3, a short value is being assigned to a variable of type byte, which is illegal. Also, the "*" operator promotes the bytes to integers, which makes it illegal to assign the return value to a variable of type byte.
9.Determine the output when the value of x is zero:
if(x >= 0)
if(x > 0)
System.out.println("x is positive");
else
System.out.println("x is negative");
None of these
"x is negative"
"x is positive"
"x is positive" and "x is negative"
The "else" statement corresponds to the second "if" in this case. To have it correspond to the first "if", curly braces
10.The control expression in an "if" statement must be:
an expression with either the type boolean or integer
an expression with type integer
an expression with type boolean
an expression with either the type boolean or integer with value 0 or 1
In the Java programming language, only expressions of type boolean are allowed as control expressions in an "if" statement.
1) What is the value of a?
2) int a = 7;
int b = 4;
a = b;
a = a + 1;
One answer only.
4
5
7
8
________________________________________
2) What output will the following line produce? System.out.println("The answer is: "+17+3);
One answer only.
The answer is: 20
The answer is: 17+3
The answer is: 173
The answer is:
________________________________________
3) What is the value of x?
4) int x = 8 / 3;
One answer only.
1
2
2.666666667
3
________________________________________
4) What is the value of y?
int y = 19 % 4;
One answer only.
2
3
4
4.75
________________________________________
5) What is the value of z?
double z = 7 / (3 + 0.5);
One answer only.
0.5
2.0
2.833333333
3.0
Question 1:
What is the value of a?
int a = 7;
int b = 4;
a = b;
a = a + 1;
Options: Your Response: Correct Answer:
4
5
7
8
see a demonstration.
________________________________________
Question 2:
What output will the following line produce?
System.out.println("The answer is: "+17+3);
Options: Your Response: Correct Answer:
The answer is: 20
The answer is: 17+3
The answer is: 173
The answer is:
see a demonstration.
________________________________________
Question 3:
What is the value of x?
int x = 8 / 3;
Options: Your Response: Correct Answer:
1
2
2.666666667
3
see a demonstration.
________________________________________
Question 4:
What is the value of y?
int y = 19 % 4;
Options: Your Response: Correct Answer:
2
3
4
4.75
see a demonstration.
________________________________________
Question 5:
What is the value of z?
double z = 7 / (3 + 0.5);
Options: Your Response: Correct Answer:
0.5
2.0
2.833333333
3.0
see a demonstration.
Monday, June 22, 2009
java multiple choice qustions - 3
Question Number 1
How can you store a copy of an object at the same time other threads may be changing the object's properties?
Choice 1
Override writeObject() in ObjectOutputStream to make it synchronized.
Choice 2
Clone the object in a block synchronized on the object and serialize the clone.
Choice 3
Nothing special, since all ObjectOutputStream methods are synchronized.
Choice 4
Implement java.io.Externalizable instead of java.io.Serializable.
Choice 5
Give the thread performing storage a higher priority than other threads.
------------------------------------------------------------
Question Number 2
Which statement about static inner classes is true?
Choice 1
Static inner classes may access any of the enclosing classes members.
Choice 2
Static inner classes may have only static methods.
Choice 3
Static inner classes may not be instantiated outside of the enclosing class.
Choice 4
Static inner classes do not have a reference to the enclosing class.
Choice 5
Static inner classes are created when the enclosing class is loaded.
------------------------------------------------------------
Question Number 3
public void createTempFiles(String d) {
File f = new File(d);
f.mkdirs();
// more code here ...
}
What is the result if the createTempFiles statement below is executed on the code above on a Unix platform?
if (System.getSecurityManager() == null)
createTempFiles( "/tmp/myfiles/_3214" );
Choice 1
A java.lang.SecurityException is thrown.
Choice 2
The file "_3214" is created in the "/tmp/myfiles" directory.
Choice 3
The "myfiles" directory is created in the "/tmp" directory.
Choice 4
A java.io.DirectoryNotCreatedException is thrown.
Choice 5
The directory "/tmp/myfiles/_3214" is created if it doesn't already exist.
------------------------------------------------------------
Question Number 4
Which one of the following is NOT a valid difference between java.awt.Canvas and Panel?
Choice 1
Canvas's can display images directly.
Choice 2
Panel can hold other components (including Canvas).
Choice 3
You can draw bit-oriented items (lines and circles) onto a Canvas.
Choice 4
Layout managers work with Panel objects.
Choice 5
Panel cannot be redrawn by a call to repaint().
------------------------------------------------------------
Question Number 5
The javadoc utility produces which one of the following?
Choice 1
A listing of key features of all classes and methods in the source document
Choice 2
An html document for each class, interface, or package
Choice 3
A document for each program that outlines flow, structure, inputs, and outputs
Choice 4
A listing of all classes and packages used by a program
Choice 5
A list of all qualified comment tags in a source document with the source code removed
------------------------------------------------------------
Question Number 6
int values[] = {1,2,3,4,5,6,7,8};
for(int i=0;i< x="0;" x=" (check().equals(" total =" 0;" i =" new" j="1;j<=" ch1 =" (char)" ch2 =" '1';" ch2 =" '2';" ch2 =" '3';" ch2 =" '4';" b =" new" c =" (C)" n1 = "n1" n2 = "n2" n3 = "n3" n4 = "inner" n2 =" n1;" n3 =" null;" i =" values.length-1;">= 0; i++)
System.out.print( values[i] + " " );
} catch (Exception e) {
System.out.print("2" + " ");
} finally {
System.out.print("3" + " ");
}
What is the output of the program above?
Choice 1
1 2
Choice 2
1 3
Choice 3
1 2 3 4 3 2 1
Choice 4
1 2 3
Choice 5
1 2 3 4 3 2 1 3
------------------------------------------------------------
Question Number 21
native int computeAll();
Referring to the above, the keyword "native" indicates which one of the following?
Choice 1
That computeAll() is undefined and must be overridden
Choice 2
That computeAll() is an external method implemented in another language
Choice 3
That computeAll() is defined in the superclass
Choice 4
That the compiler must use file computeAll.java for platform-specific code
Choice 5
That computeAll() is an operating system command
------------------------------------------------------------
Question Number 22
int i=0;
double value = 1.2;
String str = new String("1.2");
Boolean flag = true;
Which is a valid use of variable "value" as shown above?
Choice 1
value = str;
Choice 2
if(value.equals( str )) System.out.println(str);
Choice 3
if(value) i++;
Choice 4
value += flag;
Choice 5
value = ++i;
------------------------------------------------------------
Question Number 23
class A implements Cloneable {
public int i, j, k;
String str = ("Hello There");
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {}
}
}
class B extends A {
public B() {
i = 5;
j = 3;
k= -4;
}
}
Referring to the above, what will happen when the following code is executed?
B a = new B();
B b = (B) a.clone();
Choice 1
A CloneNotSupportedException is thrown.
Choice 2
Two identical class B objects are created.
Choice 3
One instance of class B is created with two pointers: "a" and "b".
Choice 4
Identical threads "a" and "b" are created.
Choice 5
Object "a" is instantiated and "b" is created as an inner class of "B".
------------------------------------------------------------
Question Number 24
What class represents the U.S. Mountain time zone in date/time calculations?
Choice 1
java.util.Locale
Choice 2
java.util.GregorianCalendar
Choice 3
java.util.Date
Choice 4
java.util.Calendar
Choice 5
java.util.SimpleTimeZone
------------------------------------------------------------
Question Number 25
public double SquareRoot( double value ) throws ArithmeticException
{
if (value >= 0) return Math.sqrt( value );
else throw new ArithmeticException();
}
public double func(int x) {
double y = (double) x;
try {
y = SquareRoot( y );
}
catch(ArithmeticException e) { y = 0; }
finally { --y; }
return y;
}
Referring to the above, what value is returned when method func(4) is invoked?
Choice 1
-2
Choice 2
-1
Choice 3
0
Choice 4
1
Choice 5
2
------------------------------------------------------------
Question Number 26
short tri[][] = new short[10][];
for(int i = 0,count =0 ; i < j =" 0" ch1="'" j =" 0;" i =" 0" ch1 =" (char)" ch1 ="=" ch1 ="=" ch1 ="=" ch1 ="=" o =" new" out =" //..." i =" I;" i =" 0;" s1 =" new" s2 =" new" s3="s1.substring(1,5)" i="0;" j="1;j0;i--) {
System.out.println("Line " + i);
}
printOut(I-1);
}
What value should be passed to the method printOut, shown above, so that ten lines will be printed?
Choice 1
2
Choice 2
3
Choice 3
4
Choice 4
5
Choice 5
6
---------------------------------------------------------------------
Question Number 6
class A {
public static void main(String args[]) {
char initial = "c";
switch (initial) {
case "j":
System.out.print("John ");
break;
case "c":
System.out.print("Chuck ");
case "t":
System.out.print("Ty ");
break;
case "s":
System.out.print("Scott ");
default:
System.out.print("All");
}
}
}
What is the output from the code above?
Choice 1
John Chuck Ty Scott All
Choice 2
A compilation error will occur.
Choice 3
Chuck Ty
Choice 4
Ty
Choice 5
Chuck
---------------------------------------------------------------------
Question Number 7
How can you insure compatibility of persistent object formats between different versions of Java?
Choice 1
Override the default ObjectInputStream and ObjectOutputStream.
Choice 2
Implement your own writeObject() and readObject() methods.
Choice 3
Add "transient" variables.
Choice 4
Implement java.io.Serializable.
Choice 5
Make the whole class transient
---------------------------------------------------------------------
Question Number 8
What does it mean if a method is final synchronized?
Choice 1
Methods which are synchronized cannot be final.
Choice 2
This is the same as declaring the method private.
Choice 3
Only one synchronized method can be invoked at a time for the entire class.
Choice 4
The method cannot be overridden and is always threadsafe.
Choice 5
All final variables referenced in the method can be modified by only one thread at a time.
---------------------------------------------------------------------
Question Number 9
class HelloWorld extends java.awt.Canvas {
String str = "Hello World";
public void paint(java.awt.Graphics g) {
java.awt.FontMetrics fm = g.getFontMetrics();
g.setColor(java.awt.Color.black);
java.awt.Dimension d = getSize();
__?__
}
}
Which one of the following code segments can be inserted into the method above to paint "Hello World" centered within the canvas?
Choice 1
g.drawText( str, 0, 0);
Choice 2
g.drawString( str, d.width/2, d.height/2 );
Choice 3
g.drawString( str, d.width/2 - fm.stringWidth(str)/2, d.height/2 -
fm.getHeight()/2);
Choice 4
g.translate( d.width/2 - fm.stringWidth(str), d.height/2 - fm.getHeight());
g.drawString( str, 0, 0);
Choice 5
g.drawText( str, d.width, d.height, Font.CENTERED );
---------------------------------------------------------------------
Question Number 10
String url=new String("http://www.tek.com");
How can you retrieve the content of the above URL?
Choice 1
Socket content = new Socket(new URL(url)).collect();
Choice 2
String content = new URLConnection(url).collect();
Choice 3
Object content = new URL(url).getContent();
Choice 4
Object content = new URLConnection(url).getContent();
Choice 5
String content = new URLHttp(url).getString();
---------------------------------------------------------------------
Question Number 11
What is NOT a typical feature of visual JavaBeans?
Choice 1
Persistence, so a bean can be customized in an application builder, saved, and reloaded later.
Choice 2
Properties, both for customization and for programmatic use.
Choice 3
Customization, so that when using an application builder a developer can customize the appearance and behavior of a bean.
Choice 4
Distributed framework, so the visual component resides on the client, while the logic resides on the server.
Choice 5
Events, so that a simple communication metaphor can be used to connect beans.
---------------------------------------------------------------------
Question Number 12
Which one of the following describes the difference between StringBuffer and String?
Choice 1
StringBuffer is used only to buffer data from an input or output stream.
Choice 2
StringBuffer allows text to be changed after instantiation.
Choice 3
StringBuffer holds zero length Strings.
Choice 4
StringBuffer supports Unicode.
Choice 5
StringBuffer is an array of Strings.
---------------------------------------------------------------------
Question Number 13
public double SquareRoot( double value ) throws ArithmeticException
{
if (value >= 0) return Math.sqrt( value );
else throw new ArithmeticException();
}
public double func(int x) {
double y = (double) x;
y *= -9.0;
try {
y = SquareRoot( y );
}
catch(ArithmeticException e) { y /= 3; }
finally { y += 10; }
return y;
}
Referring to the above, what value is returned when method func(9) is invoked?
Choice 1
-37
Choice 2
-27
Choice 3
-17
Choice 4
9
Choice 5
NaN
---------------------------------------------------------------------
Question Number 14
1: Date myDate = new Date();
2: DateFormat dateFormat = DateFormat.getDateInstance();
3: String myString = dateFormat.format(myDate);
4: System.out.println( "Today is " + myString );
How can you change line 2 above so that the date is displayed in the same format used in China?
Choice 1
java.util.Local locale = java.util.Locale.getLocale( java.util.Locale.CHINA );
DateFormat dateFormat = DateFormat.getDateInstance( locale );
Choice 2
java.util.Local locale = java.util.Locale.getLocale("China");
DateFormat dateFormat = DateFormat.getDateInstance( locale );
Choice 3
DateFormat dateFormat = DateFormat.getDateInstance();
dateFormat.setLocale( java.util.Locale.CHINA );
Choice 4
DateFormat dateFormat = DateFormat.getDateInstance(
DateFormat.SHORT, java.util.Locale.CHINA);
Choice 5
DateFormat.setLocale( java.util.Locale.CHINA );
DateFormat dateFormat = DateFormat.getDateInstance();
---------------------------------------------------------------------
Question Number 15
Which one of the following operators has a higher precedence than the modulus operator, % ?
Choice 1
-
Choice 2
*
Choice 3
+
Choice 4
/
Choice 5
. (dot)
---------------------------------------------------------------------
Question Number 16
double dd;
java.util.Random r = new Random(33);
dd = r.nextGaussian();
Referring to the above, after execution, double dd contains a value that is distributed approximately ________ with a standard deviation of ________ and mean of ________.
Choice 1
uniformly, 0, 33
Choice 2
normally, 1, 0
Choice 3
uniformly, 1, 33
Choice 4
normally, 1, 33
Choice 5
normally, 3, 3
---------------------------------------------------------------------
Question Number 17
How can you give other classes direct access to constant class attributes but avoid thread-unsafe situations?
Choice 1
Declare the attributes as public static final.
Choice 2
Implement the "java.lang.SingleThreaded" interface.
Choice 3
Declare the attributes to be synchronized.
Choice 4
This is not possible.
Choice 5
Declare the attributes as protected.
---------------------------------------------------------------------
Question Number 18
import java.io.*;
import java.net.*;
public class NetClient {
public static void main(String args[]) {
try {
Socket skt = new Socket("host",88);
In the above code, what type of connection is Socket object "skt"?
Choice 1
UDP
Choice 2
Connectionless
Choice 3
FTP
Choice 4
HTTP
Choice 5
Connection-oriented
---------------------------------------------------------------------
Question Number 19
float ff;
int gg = 99;
Referring to the above, what is the correct way to cast an integer to a float?
Choice 1
ff = (float) gg
Choice 2
ff (float) = gg
Choice 3
ff = (float: gg
Choice 4
ff = (float) %% gg
Choice 5
You cannot cast an integer to a float
---------------------------------------------------------------------
Question Number 20
Which one of the following is a reason to double-buffer animations?
Choice 1
To draw each image to the screen twice to eliminate white spots
Choice 2
To prevent "hanging" using a MediaTracker object to ensure all frames are loaded before beginning
Choice 3
To draw the next frame to an off-screen image object before displaying to eliminate flicker
Choice 4
To put multiple frame in the same file and uses cropImage() to select the desired frame
Choice 5
To use a small image as wallpaper and a transparent image as the actual frame
---------------------------------------------------------------------
Question Number 21
Which one of the following is NOT a valid java.lang.String declaration?
Choice 1
String myString = new String("Hello");
Choice 2
char data[] = {'a','b','c'};
String str = new String(data);
Choice 3
String myString = new String(5);
Choice 4
String cde = "cde";
Choice 5
String myString = new String();
---------------------------------------------------------------------
Question Number 22
int count = 0;
while(count++ < os =" System.getProperty(" f =" new" count ="=" i="0;i<5;i=" here="" fileinputstream="" store="" objectinputstream="" additional="" produce="" type="" represented="" obj="in.readObject();" others="" 33="" declares="" called="" intarray="" two="" dimensional="" arrays="" allowed="" 34="" long="" compute="" primes="" larger="" than="" minprime="minPrime;" create="" start="" thread="" primethread="" p="new" runnable="" r="new" new="" 35="" mycanvas="" extends="" count="0;" void="" public="" graphics="" all="" declare="" there="" named="" name="all[i].equals(Class.instanceOf(all[i])))" as="" its="" overloaded="" methods="" cannot="" have="" input="" different="" return="" canvas="" so="" it="" 36="" objects="" can="" cast="" another="" following="" direct="" or="" subclass="" source="" both="" classes="" are="" subclasses="" same="" abstract="" target="" final="" 37="" happens="" if="" you="" load="" jdbc="" that="" fully="" compliant="" fail="" bytecode="" would="" function="" but="" may="" work="" actions="" not="" securitymanager="" throw="" securityexception="" when="" drivermanager="" object="" will="" refuse="" register="" 38="" sign="" javakey="" tool="" does="" one="" embeds="" flag="" attributes="" bottom="" creates="" an="" inner="" containing="" data="" array="" at="" top="" file="" places="" special="" signature="" files="" jar="" bundle="" 39="" g="2.0f;" double="" expected="" value="" h="3+f%g+2;" after="" 6="" 7="" 9="" 40="" connection="" con="DriverManager.getConnection" wombat="" login="" rs="stmt.executeQuery(" c="" from="" table1="" while="" integer="" x="rs.getInt(" float="" f="new" with="" retrieval="" of="" fields="" password="" must="" encrypted="" before="" being="" sent="" driver="" s="rs.getString(" url="" wrong="" resultset="" class="" returns="" primitive="" types="" for="" integers="" and="" sql="" is="" some="" multiple="" questions="" java="" ________________________________________="" which="" code="" segment="" execute="" stored="" procedure="" located="" in="new" a="" database="" callablestatement="" cs="con.prepareCall(" storeprocedurestatement="" spstmt="connection.createStoreProcedure(" preparestatement="" pstmt="connection.prepareStatement(" statement="" stmt="con.createStatement();" referring="" to="" the="" what="" datatype="" could="" be="" returned="" by="" method="" 1="" boolean="" 2="" string="" 4="" char="" choice="" 5="" byte="" question="" number="" 3="" int="" i="0;i<10) j =" 2" i="0;i<" count="1;" n1 = "n1" n2 = "n2" n3 = "n3" n4 = "inner" n2 =" n1;" n3 =" null;" newmsg =" false;" x =" 0," y =" 5.4324;" ht =" new" v =" new" i =" 0;" e =" ht.keys();" i="0;" o =" e.nextElement();" e="ht.elements();" i =" (Integer)" e="v.elements();" i =" (Integer)" i="0;" j="0;" i =" (int)" con =" DriverManager.getConnection(url);" s = "call proc(?,?,?,?)" cs =" con.prepareCall(s);" resultset =" cs.runQuery()" i="1;i< button1 =" new" target ="=" type ="=" s = "Chase the ball." sb =" new" s =" sb.toString();" s =" sb.toString();" s =" sb.toString();" s =" sb.toString();" s =" sb.toString();" i="1;i<3); mydate =" new" dateformat =" DateFormat.getDateInstance();" mystring =" dateFormat.format(myDate);" dateformat =" DateFormat.getDateInstance();" dateformat =" DateFormat.getDateInstance(" locale =" java.util.Locale.getLocale(" dateformat =" DateFormat.getDateInstance(" dateformat =" DateFormat.getDateInstance();" locale =" java.util.Locale.getLocale(" dateformat =" DateFormat.getDateInstance(" minprime =" minPrime;" p =" new" r =" new" p =" new" i =" 0;" j =" 0;" i="=">j) continue big_loop;
System.out.print("A ");
}
}
finally {
System.out.print("B ");
}
System.out.print("C ");
}
What is the output from the program above?
Choice 1
A B C A B C A B C
Choice 2
A A A B C A A A B C A A A B C
Choice 3
A A B C B B
Choice 4
A A B B C A C A
Choice 5
None. The program will enter into an infinite loop.
How can you store a copy of an object at the same time other threads may be changing the object's properties?
Choice 1
Override writeObject() in ObjectOutputStream to make it synchronized.
Choice 2
Clone the object in a block synchronized on the object and serialize the clone.
Choice 3
Nothing special, since all ObjectOutputStream methods are synchronized.
Choice 4
Implement java.io.Externalizable instead of java.io.Serializable.
Choice 5
Give the thread performing storage a higher priority than other threads.
------------------------------------------------------------
Question Number 2
Which statement about static inner classes is true?
Choice 1
Static inner classes may access any of the enclosing classes members.
Choice 2
Static inner classes may have only static methods.
Choice 3
Static inner classes may not be instantiated outside of the enclosing class.
Choice 4
Static inner classes do not have a reference to the enclosing class.
Choice 5
Static inner classes are created when the enclosing class is loaded.
------------------------------------------------------------
Question Number 3
public void createTempFiles(String d) {
File f = new File(d);
f.mkdirs();
// more code here ...
}
What is the result if the createTempFiles statement below is executed on the code above on a Unix platform?
if (System.getSecurityManager() == null)
createTempFiles( "/tmp/myfiles/_3214" );
Choice 1
A java.lang.SecurityException is thrown.
Choice 2
The file "_3214" is created in the "/tmp/myfiles" directory.
Choice 3
The "myfiles" directory is created in the "/tmp" directory.
Choice 4
A java.io.DirectoryNotCreatedException is thrown.
Choice 5
The directory "/tmp/myfiles/_3214" is created if it doesn't already exist.
------------------------------------------------------------
Question Number 4
Which one of the following is NOT a valid difference between java.awt.Canvas and Panel?
Choice 1
Canvas's can display images directly.
Choice 2
Panel can hold other components (including Canvas).
Choice 3
You can draw bit-oriented items (lines and circles) onto a Canvas.
Choice 4
Layout managers work with Panel objects.
Choice 5
Panel cannot be redrawn by a call to repaint().
------------------------------------------------------------
Question Number 5
The javadoc utility produces which one of the following?
Choice 1
A listing of key features of all classes and methods in the source document
Choice 2
An html document for each class, interface, or package
Choice 3
A document for each program that outlines flow, structure, inputs, and outputs
Choice 4
A listing of all classes and packages used by a program
Choice 5
A list of all qualified comment tags in a source document with the source code removed
------------------------------------------------------------
Question Number 6
int values[] = {1,2,3,4,5,6,7,8};
for(int i=0;i< x="0;" x=" (check().equals(" total =" 0;" i =" new" j="1;j<=" ch1 =" (char)" ch2 =" '1';" ch2 =" '2';" ch2 =" '3';" ch2 =" '4';" b =" new" c =" (C)" n1 = "n1" n2 = "n2" n3 = "n3" n4 = "inner" n2 =" n1;" n3 =" null;" i =" values.length-1;">= 0; i++)
System.out.print( values[i] + " " );
} catch (Exception e) {
System.out.print("2" + " ");
} finally {
System.out.print("3" + " ");
}
What is the output of the program above?
Choice 1
1 2
Choice 2
1 3
Choice 3
1 2 3 4 3 2 1
Choice 4
1 2 3
Choice 5
1 2 3 4 3 2 1 3
------------------------------------------------------------
Question Number 21
native int computeAll();
Referring to the above, the keyword "native" indicates which one of the following?
Choice 1
That computeAll() is undefined and must be overridden
Choice 2
That computeAll() is an external method implemented in another language
Choice 3
That computeAll() is defined in the superclass
Choice 4
That the compiler must use file computeAll.java for platform-specific code
Choice 5
That computeAll() is an operating system command
------------------------------------------------------------
Question Number 22
int i=0;
double value = 1.2;
String str = new String("1.2");
Boolean flag = true;
Which is a valid use of variable "value" as shown above?
Choice 1
value = str;
Choice 2
if(value.equals( str )) System.out.println(str);
Choice 3
if(value) i++;
Choice 4
value += flag;
Choice 5
value = ++i;
------------------------------------------------------------
Question Number 23
class A implements Cloneable {
public int i, j, k;
String str = ("Hello There");
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {}
}
}
class B extends A {
public B() {
i = 5;
j = 3;
k= -4;
}
}
Referring to the above, what will happen when the following code is executed?
B a = new B();
B b = (B) a.clone();
Choice 1
A CloneNotSupportedException is thrown.
Choice 2
Two identical class B objects are created.
Choice 3
One instance of class B is created with two pointers: "a" and "b".
Choice 4
Identical threads "a" and "b" are created.
Choice 5
Object "a" is instantiated and "b" is created as an inner class of "B".
------------------------------------------------------------
Question Number 24
What class represents the U.S. Mountain time zone in date/time calculations?
Choice 1
java.util.Locale
Choice 2
java.util.GregorianCalendar
Choice 3
java.util.Date
Choice 4
java.util.Calendar
Choice 5
java.util.SimpleTimeZone
------------------------------------------------------------
Question Number 25
public double SquareRoot( double value ) throws ArithmeticException
{
if (value >= 0) return Math.sqrt( value );
else throw new ArithmeticException();
}
public double func(int x) {
double y = (double) x;
try {
y = SquareRoot( y );
}
catch(ArithmeticException e) { y = 0; }
finally { --y; }
return y;
}
Referring to the above, what value is returned when method func(4) is invoked?
Choice 1
-2
Choice 2
-1
Choice 3
0
Choice 4
1
Choice 5
2
------------------------------------------------------------
Question Number 26
short tri[][] = new short[10][];
for(int i = 0,count =0 ; i < j =" 0" ch1="'" j =" 0;" i =" 0" ch1 =" (char)" ch1 ="=" ch1 ="=" ch1 ="=" ch1 ="=" o =" new" out =" //..." i =" I;" i =" 0;" s1 =" new" s2 =" new" s3="s1.substring(1,5)" i="0;" j="1;j
System.out.println("Line " + i);
}
printOut(I-1);
}
What value should be passed to the method printOut, shown above, so that ten lines will be printed?
Choice 1
2
Choice 2
3
Choice 3
4
Choice 4
5
Choice 5
6
---------------------------------------------------------------------
Question Number 6
class A {
public static void main(String args[]) {
char initial = "c";
switch (initial) {
case "j":
System.out.print("John ");
break;
case "c":
System.out.print("Chuck ");
case "t":
System.out.print("Ty ");
break;
case "s":
System.out.print("Scott ");
default:
System.out.print("All");
}
}
}
What is the output from the code above?
Choice 1
John Chuck Ty Scott All
Choice 2
A compilation error will occur.
Choice 3
Chuck Ty
Choice 4
Ty
Choice 5
Chuck
---------------------------------------------------------------------
Question Number 7
How can you insure compatibility of persistent object formats between different versions of Java?
Choice 1
Override the default ObjectInputStream and ObjectOutputStream.
Choice 2
Implement your own writeObject() and readObject() methods.
Choice 3
Add "transient" variables.
Choice 4
Implement java.io.Serializable.
Choice 5
Make the whole class transient
---------------------------------------------------------------------
Question Number 8
What does it mean if a method is final synchronized?
Choice 1
Methods which are synchronized cannot be final.
Choice 2
This is the same as declaring the method private.
Choice 3
Only one synchronized method can be invoked at a time for the entire class.
Choice 4
The method cannot be overridden and is always threadsafe.
Choice 5
All final variables referenced in the method can be modified by only one thread at a time.
---------------------------------------------------------------------
Question Number 9
class HelloWorld extends java.awt.Canvas {
String str = "Hello World";
public void paint(java.awt.Graphics g) {
java.awt.FontMetrics fm = g.getFontMetrics();
g.setColor(java.awt.Color.black);
java.awt.Dimension d = getSize();
__?__
}
}
Which one of the following code segments can be inserted into the method above to paint "Hello World" centered within the canvas?
Choice 1
g.drawText( str, 0, 0);
Choice 2
g.drawString( str, d.width/2, d.height/2 );
Choice 3
g.drawString( str, d.width/2 - fm.stringWidth(str)/2, d.height/2 -
fm.getHeight()/2);
Choice 4
g.translate( d.width/2 - fm.stringWidth(str), d.height/2 - fm.getHeight());
g.drawString( str, 0, 0);
Choice 5
g.drawText( str, d.width, d.height, Font.CENTERED );
---------------------------------------------------------------------
Question Number 10
String url=new String("http://www.tek.com");
How can you retrieve the content of the above URL?
Choice 1
Socket content = new Socket(new URL(url)).collect();
Choice 2
String content = new URLConnection(url).collect();
Choice 3
Object content = new URL(url).getContent();
Choice 4
Object content = new URLConnection(url).getContent();
Choice 5
String content = new URLHttp(url).getString();
---------------------------------------------------------------------
Question Number 11
What is NOT a typical feature of visual JavaBeans?
Choice 1
Persistence, so a bean can be customized in an application builder, saved, and reloaded later.
Choice 2
Properties, both for customization and for programmatic use.
Choice 3
Customization, so that when using an application builder a developer can customize the appearance and behavior of a bean.
Choice 4
Distributed framework, so the visual component resides on the client, while the logic resides on the server.
Choice 5
Events, so that a simple communication metaphor can be used to connect beans.
---------------------------------------------------------------------
Question Number 12
Which one of the following describes the difference between StringBuffer and String?
Choice 1
StringBuffer is used only to buffer data from an input or output stream.
Choice 2
StringBuffer allows text to be changed after instantiation.
Choice 3
StringBuffer holds zero length Strings.
Choice 4
StringBuffer supports Unicode.
Choice 5
StringBuffer is an array of Strings.
---------------------------------------------------------------------
Question Number 13
public double SquareRoot( double value ) throws ArithmeticException
{
if (value >= 0) return Math.sqrt( value );
else throw new ArithmeticException();
}
public double func(int x) {
double y = (double) x;
y *= -9.0;
try {
y = SquareRoot( y );
}
catch(ArithmeticException e) { y /= 3; }
finally { y += 10; }
return y;
}
Referring to the above, what value is returned when method func(9) is invoked?
Choice 1
-37
Choice 2
-27
Choice 3
-17
Choice 4
9
Choice 5
NaN
---------------------------------------------------------------------
Question Number 14
1: Date myDate = new Date();
2: DateFormat dateFormat = DateFormat.getDateInstance();
3: String myString = dateFormat.format(myDate);
4: System.out.println( "Today is " + myString );
How can you change line 2 above so that the date is displayed in the same format used in China?
Choice 1
java.util.Local locale = java.util.Locale.getLocale( java.util.Locale.CHINA );
DateFormat dateFormat = DateFormat.getDateInstance( locale );
Choice 2
java.util.Local locale = java.util.Locale.getLocale("China");
DateFormat dateFormat = DateFormat.getDateInstance( locale );
Choice 3
DateFormat dateFormat = DateFormat.getDateInstance();
dateFormat.setLocale( java.util.Locale.CHINA );
Choice 4
DateFormat dateFormat = DateFormat.getDateInstance(
DateFormat.SHORT, java.util.Locale.CHINA);
Choice 5
DateFormat.setLocale( java.util.Locale.CHINA );
DateFormat dateFormat = DateFormat.getDateInstance();
---------------------------------------------------------------------
Question Number 15
Which one of the following operators has a higher precedence than the modulus operator, % ?
Choice 1
-
Choice 2
*
Choice 3
+
Choice 4
/
Choice 5
. (dot)
---------------------------------------------------------------------
Question Number 16
double dd;
java.util.Random r = new Random(33);
dd = r.nextGaussian();
Referring to the above, after execution, double dd contains a value that is distributed approximately ________ with a standard deviation of ________ and mean of ________.
Choice 1
uniformly, 0, 33
Choice 2
normally, 1, 0
Choice 3
uniformly, 1, 33
Choice 4
normally, 1, 33
Choice 5
normally, 3, 3
---------------------------------------------------------------------
Question Number 17
How can you give other classes direct access to constant class attributes but avoid thread-unsafe situations?
Choice 1
Declare the attributes as public static final.
Choice 2
Implement the "java.lang.SingleThreaded" interface.
Choice 3
Declare the attributes to be synchronized.
Choice 4
This is not possible.
Choice 5
Declare the attributes as protected.
---------------------------------------------------------------------
Question Number 18
import java.io.*;
import java.net.*;
public class NetClient {
public static void main(String args[]) {
try {
Socket skt = new Socket("host",88);
In the above code, what type of connection is Socket object "skt"?
Choice 1
UDP
Choice 2
Connectionless
Choice 3
FTP
Choice 4
HTTP
Choice 5
Connection-oriented
---------------------------------------------------------------------
Question Number 19
float ff;
int gg = 99;
Referring to the above, what is the correct way to cast an integer to a float?
Choice 1
ff = (float) gg
Choice 2
ff (float) = gg
Choice 3
ff = (float: gg
Choice 4
ff = (float) %% gg
Choice 5
You cannot cast an integer to a float
---------------------------------------------------------------------
Question Number 20
Which one of the following is a reason to double-buffer animations?
Choice 1
To draw each image to the screen twice to eliminate white spots
Choice 2
To prevent "hanging" using a MediaTracker object to ensure all frames are loaded before beginning
Choice 3
To draw the next frame to an off-screen image object before displaying to eliminate flicker
Choice 4
To put multiple frame in the same file and uses cropImage() to select the desired frame
Choice 5
To use a small image as wallpaper and a transparent image as the actual frame
---------------------------------------------------------------------
Question Number 21
Which one of the following is NOT a valid java.lang.String declaration?
Choice 1
String myString = new String("Hello");
Choice 2
char data[] = {'a','b','c'};
String str = new String(data);
Choice 3
String myString = new String(5);
Choice 4
String cde = "cde";
Choice 5
String myString = new String();
---------------------------------------------------------------------
Question Number 22
int count = 0;
while(count++ < os =" System.getProperty(" f =" new" count ="=" i="0;i<5;i=" here="" fileinputstream="" store="" objectinputstream="" additional="" produce="" type="" represented="" obj="in.readObject();" others="" 33="" declares="" called="" intarray="" two="" dimensional="" arrays="" allowed="" 34="" long="" compute="" primes="" larger="" than="" minprime="minPrime;" create="" start="" thread="" primethread="" p="new" runnable="" r="new" new="" 35="" mycanvas="" extends="" count="0;" void="" public="" graphics="" all="" declare="" there="" named="" name="all[i].equals(Class.instanceOf(all[i])))" as="" its="" overloaded="" methods="" cannot="" have="" input="" different="" return="" canvas="" so="" it="" 36="" objects="" can="" cast="" another="" following="" direct="" or="" subclass="" source="" both="" classes="" are="" subclasses="" same="" abstract="" target="" final="" 37="" happens="" if="" you="" load="" jdbc="" that="" fully="" compliant="" fail="" bytecode="" would="" function="" but="" may="" work="" actions="" not="" securitymanager="" throw="" securityexception="" when="" drivermanager="" object="" will="" refuse="" register="" 38="" sign="" javakey="" tool="" does="" one="" embeds="" flag="" attributes="" bottom="" creates="" an="" inner="" containing="" data="" array="" at="" top="" file="" places="" special="" signature="" files="" jar="" bundle="" 39="" g="2.0f;" double="" expected="" value="" h="3+f%g+2;" after="" 6="" 7="" 9="" 40="" connection="" con="DriverManager.getConnection" wombat="" login="" rs="stmt.executeQuery(" c="" from="" table1="" while="" integer="" x="rs.getInt(" float="" f="new" with="" retrieval="" of="" fields="" password="" must="" encrypted="" before="" being="" sent="" driver="" s="rs.getString(" url="" wrong="" resultset="" class="" returns="" primitive="" types="" for="" integers="" and="" sql="" is="" some="" multiple="" questions="" java="" ________________________________________="" which="" code="" segment="" execute="" stored="" procedure="" located="" in="new" a="" database="" callablestatement="" cs="con.prepareCall(" storeprocedurestatement="" spstmt="connection.createStoreProcedure(" preparestatement="" pstmt="connection.prepareStatement(" statement="" stmt="con.createStatement();" referring="" to="" the="" what="" datatype="" could="" be="" returned="" by="" method="" 1="" boolean="" 2="" string="" 4="" char="" choice="" 5="" byte="" question="" number="" 3="" int="" i="0;i
System.out.print("A ");
}
}
finally {
System.out.print("B ");
}
System.out.print("C ");
}
What is the output from the program above?
Choice 1
A B C A B C A B C
Choice 2
A A A B C A A A B C A A A B C
Choice 3
A A B C B B
Choice 4
A A B B C A C A
Choice 5
None. The program will enter into an infinite loop.
Core java questions-2
Question Number 1
How can you store a copy of an object at the same time other threads may be changing the object's properties?
Choice 1
Override writeObject() in ObjectOutputStream to make it synchronized.
Choice 2
Clone the object in a block synchronized on the object and serialize the clone.
Choice 3
Nothing special, since all ObjectOutputStream methods are synchronized.
Choice 4
Implement java.io.Externalizable instead of java.io.Serializable.
Choice 5
Give the thread performing storage a higher priority than other threads.
------------------------------------------------------------
Question Number 2
Which statement about static inner classes is true?
Choice 1
Static inner classes may access any of the enclosing classes members.
Choice 2
Static inner classes may have only static methods.
Choice 3
Static inner classes may not be instantiated outside of the enclosing class.
Choice 4
Static inner classes do not have a reference to the enclosing class.
Choice 5
Static inner classes are created when the enclosing class is loaded.
------------------------------------------------------------
Question Number 3
public void createTempFiles(String d) {
File f = new File(d);
f.mkdirs();
// more code here ...
}
What is the result if the createTempFiles statement below is executed on the code above on a Unix platform?
if (System.getSecurityManager() == null)
createTempFiles( "/tmp/myfiles/_3214" );
Choice 1
A java.lang.SecurityException is thrown.
Choice 2
The file "_3214" is created in the "/tmp/myfiles" directory.
Choice 3
The "myfiles" directory is created in the "/tmp" directory.
Choice 4
A java.io.DirectoryNotCreatedException is thrown.
Choice 5
The directory "/tmp/myfiles/_3214" is created if it doesn't already exist.
------------------------------------------------------------
Question Number 4
Which one of the following is NOT a valid difference between java.awt.Canvas and Panel?
Choice 1
Canvas's can display images directly.
Choice 2
Panel can hold other components (including Canvas).
Choice 3
You can draw bit-oriented items (lines and circles) onto a Canvas.
Choice 4
Layout managers work with Panel objects.
Choice 5
Panel cannot be redrawn by a call to repaint().
------------------------------------------------------------
Question Number 5
The javadoc utility produces which one of the following?
Choice 1
A listing of key features of all classes and methods in the source document
Choice 2
An html document for each class, interface, or package
Choice 3
A document for each program that outlines flow, structure, inputs, and outputs
Choice 4
A listing of all classes and packages used by a program
Choice 5
A list of all qualified comment tags in a source document with the source code removed
------------------------------------------------------------
Question Number 6
int values[] = {1,2,3,4,5,6,7,8};
for(int i=0;i< x="0;" x=" (check().equals(" total =" 0;" i =" new" j="1;j<=" ch1 =" (char)" ch2 =" '1';" ch2 =" '2';" ch2 =" '3';" ch2 =" '4';" b =" new" c =" (C)" n1 = "n1" n2 = "n2" n3 = "n3" n4 = "inner" n2 =" n1;" n3 =" null;" i =" values.length-1;">= 0; i++)
System.out.print( values[i] + " " );
} catch (Exception e) {
System.out.print("2" + " ");
} finally {
System.out.print("3" + " ");
}
What is the output of the program above?
Choice 1
1 2
Choice 2
1 3
Choice 3
1 2 3 4 3 2 1
Choice 4
1 2 3
Choice 5
1 2 3 4 3 2 1 3
------------------------------------------------------------
Question Number 21
native int computeAll();
Referring to the above, the keyword "native" indicates which one of the following?
Choice 1
That computeAll() is undefined and must be overridden
Choice 2
That computeAll() is an external method implemented in another language
Choice 3
That computeAll() is defined in the superclass
Choice 4
That the compiler must use file computeAll.java for platform-specific code
Choice 5
That computeAll() is an operating system command
------------------------------------------------------------
Question Number 22
int i=0;
double value = 1.2;
String str = new String("1.2");
Boolean flag = true;
Which is a valid use of variable "value" as shown above?
Choice 1
value = str;
Choice 2
if(value.equals( str )) System.out.println(str);
Choice 3
if(value) i++;
Choice 4
value += flag;
Choice 5
value = ++i;
------------------------------------------------------------
Question Number 23
class A implements Cloneable {
public int i, j, k;
String str = ("Hello There");
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {}
}
}
class B extends A {
public B() {
i = 5;
j = 3;
k= -4;
}
}
Referring to the above, what will happen when the following code is executed?
B a = new B();
B b = (B) a.clone();
Choice 1
A CloneNotSupportedException is thrown.
Choice 2
Two identical class B objects are created.
Choice 3
One instance of class B is created with two pointers: "a" and "b".
Choice 4
Identical threads "a" and "b" are created.
Choice 5
Object "a" is instantiated and "b" is created as an inner class of "B".
------------------------------------------------------------
Question Number 24
What class represents the U.S. Mountain time zone in date/time calculations?
Choice 1
java.util.Locale
Choice 2
java.util.GregorianCalendar
Choice 3
java.util.Date
Choice 4
java.util.Calendar
Choice 5
java.util.SimpleTimeZone
------------------------------------------------------------
Question Number 25
public double SquareRoot( double value ) throws ArithmeticException
{
if (value >= 0) return Math.sqrt( value );
else throw new ArithmeticException();
}
public double func(int x) {
double y = (double) x;
try {
y = SquareRoot( y );
}
catch(ArithmeticException e) { y = 0; }
finally { --y; }
return y;
}
Referring to the above, what value is returned when method func(4) is invoked?
Choice 1
-2
Choice 2
-1
Choice 3
0
Choice 4
1
Choice 5
2
------------------------------------------------------------
Question Number 26
short tri[][] = new short[10][];
for(int i = 0,count =0 ; i < j =" 0" ch1="'" j =" 0;" i =" 0" ch1 =" (char)" ch1 ="=" ch1 ="=" ch1 ="=" ch1 ="=" o =" new" out =" //..." i =" I;" i =" 0;" s1 =" new" s2 =" new" s3="s1.substring(1,5)" i="0;" j="1;jwidget shown above is similar to which standard java.awt class?
Choice 1
Menu
Choice 2
PullMenu
Choice 3
List
Choice 4
Choice
Choice 5
Select
------------------------------------------------------------
Question Number 40
What class is subclassed to package several locale-specific versions of a set of greetings used by an application?
Choice 1
java.text.RuleBasedCollator
Choice 2
java.text.CollationKey
Choice 3
java.util.ResourceBundle
Choice 4
java.util.TimeZone
Choice 5
java.util.Locale
How can you store a copy of an object at the same time other threads may be changing the object's properties?
Choice 1
Override writeObject() in ObjectOutputStream to make it synchronized.
Choice 2
Clone the object in a block synchronized on the object and serialize the clone.
Choice 3
Nothing special, since all ObjectOutputStream methods are synchronized.
Choice 4
Implement java.io.Externalizable instead of java.io.Serializable.
Choice 5
Give the thread performing storage a higher priority than other threads.
------------------------------------------------------------
Question Number 2
Which statement about static inner classes is true?
Choice 1
Static inner classes may access any of the enclosing classes members.
Choice 2
Static inner classes may have only static methods.
Choice 3
Static inner classes may not be instantiated outside of the enclosing class.
Choice 4
Static inner classes do not have a reference to the enclosing class.
Choice 5
Static inner classes are created when the enclosing class is loaded.
------------------------------------------------------------
Question Number 3
public void createTempFiles(String d) {
File f = new File(d);
f.mkdirs();
// more code here ...
}
What is the result if the createTempFiles statement below is executed on the code above on a Unix platform?
if (System.getSecurityManager() == null)
createTempFiles( "/tmp/myfiles/_3214" );
Choice 1
A java.lang.SecurityException is thrown.
Choice 2
The file "_3214" is created in the "/tmp/myfiles" directory.
Choice 3
The "myfiles" directory is created in the "/tmp" directory.
Choice 4
A java.io.DirectoryNotCreatedException is thrown.
Choice 5
The directory "/tmp/myfiles/_3214" is created if it doesn't already exist.
------------------------------------------------------------
Question Number 4
Which one of the following is NOT a valid difference between java.awt.Canvas and Panel?
Choice 1
Canvas's can display images directly.
Choice 2
Panel can hold other components (including Canvas).
Choice 3
You can draw bit-oriented items (lines and circles) onto a Canvas.
Choice 4
Layout managers work with Panel objects.
Choice 5
Panel cannot be redrawn by a call to repaint().
------------------------------------------------------------
Question Number 5
The javadoc utility produces which one of the following?
Choice 1
A listing of key features of all classes and methods in the source document
Choice 2
An html document for each class, interface, or package
Choice 3
A document for each program that outlines flow, structure, inputs, and outputs
Choice 4
A listing of all classes and packages used by a program
Choice 5
A list of all qualified comment tags in a source document with the source code removed
------------------------------------------------------------
Question Number 6
int values[] = {1,2,3,4,5,6,7,8};
for(int i=0;i< x="0;" x=" (check().equals(" total =" 0;" i =" new" j="1;j<=" ch1 =" (char)" ch2 =" '1';" ch2 =" '2';" ch2 =" '3';" ch2 =" '4';" b =" new" c =" (C)" n1 = "n1" n2 = "n2" n3 = "n3" n4 = "inner" n2 =" n1;" n3 =" null;" i =" values.length-1;">= 0; i++)
System.out.print( values[i] + " " );
} catch (Exception e) {
System.out.print("2" + " ");
} finally {
System.out.print("3" + " ");
}
What is the output of the program above?
Choice 1
1 2
Choice 2
1 3
Choice 3
1 2 3 4 3 2 1
Choice 4
1 2 3
Choice 5
1 2 3 4 3 2 1 3
------------------------------------------------------------
Question Number 21
native int computeAll();
Referring to the above, the keyword "native" indicates which one of the following?
Choice 1
That computeAll() is undefined and must be overridden
Choice 2
That computeAll() is an external method implemented in another language
Choice 3
That computeAll() is defined in the superclass
Choice 4
That the compiler must use file computeAll.java for platform-specific code
Choice 5
That computeAll() is an operating system command
------------------------------------------------------------
Question Number 22
int i=0;
double value = 1.2;
String str = new String("1.2");
Boolean flag = true;
Which is a valid use of variable "value" as shown above?
Choice 1
value = str;
Choice 2
if(value.equals( str )) System.out.println(str);
Choice 3
if(value) i++;
Choice 4
value += flag;
Choice 5
value = ++i;
------------------------------------------------------------
Question Number 23
class A implements Cloneable {
public int i, j, k;
String str = ("Hello There");
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {}
}
}
class B extends A {
public B() {
i = 5;
j = 3;
k= -4;
}
}
Referring to the above, what will happen when the following code is executed?
B a = new B();
B b = (B) a.clone();
Choice 1
A CloneNotSupportedException is thrown.
Choice 2
Two identical class B objects are created.
Choice 3
One instance of class B is created with two pointers: "a" and "b".
Choice 4
Identical threads "a" and "b" are created.
Choice 5
Object "a" is instantiated and "b" is created as an inner class of "B".
------------------------------------------------------------
Question Number 24
What class represents the U.S. Mountain time zone in date/time calculations?
Choice 1
java.util.Locale
Choice 2
java.util.GregorianCalendar
Choice 3
java.util.Date
Choice 4
java.util.Calendar
Choice 5
java.util.SimpleTimeZone
------------------------------------------------------------
Question Number 25
public double SquareRoot( double value ) throws ArithmeticException
{
if (value >= 0) return Math.sqrt( value );
else throw new ArithmeticException();
}
public double func(int x) {
double y = (double) x;
try {
y = SquareRoot( y );
}
catch(ArithmeticException e) { y = 0; }
finally { --y; }
return y;
}
Referring to the above, what value is returned when method func(4) is invoked?
Choice 1
-2
Choice 2
-1
Choice 3
0
Choice 4
1
Choice 5
2
------------------------------------------------------------
Question Number 26
short tri[][] = new short[10][];
for(int i = 0,count =0 ; i < j =" 0" ch1="'" j =" 0;" i =" 0" ch1 =" (char)" ch1 ="=" ch1 ="=" ch1 ="=" ch1 ="=" o =" new" out =" //..." i =" I;" i =" 0;" s1 =" new" s2 =" new" s3="s1.substring(1,5)" i="0;" j="1;j
Choice 1
Menu
Choice 2
PullMenu
Choice 3
List
Choice 4
Choice
Choice 5
Select
------------------------------------------------------------
Question Number 40
What class is subclassed to package several locale-specific versions of a set of greetings used by an application?
Choice 1
java.text.RuleBasedCollator
Choice 2
java.text.CollationKey
Choice 3
java.util.ResourceBundle
Choice 4
java.util.TimeZone
Choice 5
java.util.Locale
core java questions - 1
Some Multiple choice questions in Java
Question Number 1
Which code segment could execute the stored procedure "countRecs()" located in a database server?
Choice 1
Statement stmt = connection.createStatement();
stmt.execute("COUNTRECS()");
Choice 2
CallableStatement cs = con.prepareCall("{call COUNTRECS}");
cs.executeQuery();
Choice 3
StoreProcedureStatement spstmt = connection.createStoreProcedure("countRecs()");
spstmt.executeQuery();
Choice 4
PrepareStatement pstmt = connection.prepareStatement("countRecs()");
pstmt.execute();
Choice 5
Statement stmt = connection.createStatement();
stmt.executeStoredProcedure("countRecs()");
------------------------------------------------------------
Question Number 2
if(check4Biz(storeNum) != null) {}
Referring to the above, what datatype could be returned by method check4Biz()?
Choice 1
Boolean
Choice 2
int
Choice 3
String
Choice 4
char
Choice 5
byte
------------------------------------------------------------
Question Number 3
int j;
for(int i=0;i<14;i++) j =" 2" i="0;i<" count="1;" id="KonaLink0" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://go4experts.blogspot.com/"> system will exit
------------------------------------------------------------
Question Number 7
System.getProperties().put(
"java.rmi.server.codebase",
"http://www.domain.com/classes/");
Which one of the following is a capability of the above code?
Choice 1
Override CLASSPATH
Choice 2
Register an rmi server on its host system
Choice 3
Set the location of all applets in a web server
Choice 4
Append CLASSPATH
Choice 5
Facilitate dynamic class loading for remote objects
------------------------------------------------------------
Question Number 8
Which one of the following statements is FALSE?
Choice 1
Java supports multi-threaded programming.
Choice 2
Threads in a single program can have different priorities.
Choice 3
Multiple threads can manipulate files and get user input at the same time.
Choice 4
Two threads can never act on the same object at the same time.
Choice 5
Threads are created and started with different methods.
------------------------------------------------------------
Question Number 9
1 public static void main(String[] s) {
2 String n1, n2, n3;
3 n1 = "n1";
4 n2 = "n2";
5 n3 = "n3";
6 {
7 String n4 = "inner";
8 n2 = n1;
9 }
10 n3 = null;
11 }
How many instances of the String will be eligible for garbage collection after line 10 in the above code snippet is executed?
Choice 1
0
Choice 2
1
Choice 3
2
Choice 4
3
Choice 5
The code will not compile.
------------------------------------------------------------
Question Number 10
Which code declares class A to belong to the mypackage.financial package?
Choice 1
package mypackage;
package financial;
Choice 2
import mypackage.*;
Choice 3
package mypackage.financial.A;
Choice 4
import mypackage.financial.*;
Choice 5
package mypackage.financial;
Which code segment could execute the stored procedure "countRecs()" located in a database server?
Choice 1
Statement stmt = connection.createStatement();
stmt.execute("COUNTRECS()");
Choice 2
CallableStatement cs = con.prepareCall("{call COUNTRECS}");
cs.executeQuery();
Choice 3
StoreProcedureStatement spstmt = connection.createStoreProcedure("countRecs()");
spstmt.executeQuery();
Choice 4
PrepareStatement pstmt = connection.prepareStatement("countRecs()");
pstmt.execute();
Choice 5
Statement stmt = connection.createStatement();
stmt.executeStoredProcedure("countRecs()");
------------------------------------------------------------
Question Number 2
if(check4Biz(storeNum) != null) {}
Referring to the above, what datatype could be returned by method check4Biz()?
Choice 1
Boolean
Choice 2
int
Choice 3
String
Choice 4
char
Choice 5
byte
------------------------------------------------------------
Question Number 3
int j;
for(int i=0;i<14;i++) j =" 2" i="0;i<" count="1;" id="KonaLink0" target="undefined" class="kLink" style="text-decoration: underline ! important; position: static;" href="http://go4experts.blogspot.com/"> system will exit
------------------------------------------------------------
Question Number 7
System.getProperties().put(
"java.rmi.server.codebase",
"http://www.domain.com/classes/");
Which one of the following is a capability of the above code?
Choice 1
Override CLASSPATH
Choice 2
Register an rmi server on its host system
Choice 3
Set the location of all applets in a web server
Choice 4
Append CLASSPATH
Choice 5
Facilitate dynamic class loading for remote objects
------------------------------------------------------------
Question Number 8
Which one of the following statements is FALSE?
Choice 1
Java supports multi-threaded programming.
Choice 2
Threads in a single program can have different priorities.
Choice 3
Multiple threads can manipulate files and get user input at the same time.
Choice 4
Two threads can never act on the same object at the same time.
Choice 5
Threads are created and started with different methods.
------------------------------------------------------------
Question Number 9
1 public static void main(String[] s) {
2 String n1, n2, n3;
3 n1 = "n1";
4 n2 = "n2";
5 n3 = "n3";
6 {
7 String n4 = "inner";
8 n2 = n1;
9 }
10 n3 = null;
11 }
How many instances of the String will be eligible for garbage collection after line 10 in the above code snippet is executed?
Choice 1
0
Choice 2
1
Choice 3
2
Choice 4
3
Choice 5
The code will not compile.
------------------------------------------------------------
Question Number 10
Which code declares class A to belong to the mypackage.financial package?
Choice 1
package mypackage;
package financial;
Choice 2
import mypackage.*;
Choice 3
package mypackage.financial.A;
Choice 4
import mypackage.financial.*;
Choice 5
package mypackage.financial;
Subscribe to:
Posts (Atom)