Quizzes
Search
Take Quizzes
Animal
Nutrition
Love
Relationship
Computer
Sports
Society
Business
Geography
Language
Personality
Harry Potter
Movie
Television
Music
Online Exam
Health
Country
Art
Entertainment
Celebrity
Math
Game
Book
Fun
Science
Food
History
Education
All Topics
Create a Quiz
Quiz Maker
Training Maker
Survey Maker
Flashcards
Brain Games
See All
ProProfs.com
Search
Create A Quiz
Take Quizzes
Animal
Nutrition
Love
Relationship
Computer
Sports
Society
Business
Geography
Language
Personality
Harry Potter
Movie
Television
Music
Online Exam
Health
Country
Art
Entertainment
Celebrity
Math
Game
Book
Fun
Science
Food
History
Education
All Topics
Products
Quiz Maker
Training Maker
Survey Maker
Flashcards
Brain Games
See All
ProProfs.com
Quizzes
Quizzes
›
Computer
›
Software
Dd3
44 Questions
|
By Unrealvicky | Updated: Jul 30, 2011
| Attempts: 739
Share
Quiz
Flashcard
Start
Share on Facebook
Share on Twitter
Share on Whatsapp
Share on Pinterest
Share on Email
Copy to Clipboard
Embed on your website
Question
1
/ 44
0 %
0/100
Score
0/100
1.
Which of the following methods is used to check whether ResultSet object contains records?
Last()
HasRecords()
Previous()
Next()
First()
Submit
Start Quiz
About This Quiz
2.
What's your name?
We’ll put your name on your report, certificate, and leaderboard.
2.
Consider the following program: class A implements Runnable { public void run() { System.out.print(Thread.currentThread().getName()); } } class B implements Runnable { public void run() { new A().run(); new Thread(new A(),"T2").run(); new Thread(new A(),"T3").start(); } } class C { public static void main (String[] args) { new Thread(new B(),"T1").start(); } } What will be the output of the above program?
Prints: T1T2T2
Prints: T1T2T3
Prints: T1T1T2
Prints: T1T1T3
Prints: T1T1T1
Submit
3.
Consider the following code snippet: import java.util.*; import java.text.*; public class TestCol5 { public static void main(String[] args) { String dob = "17/03/1981"; // Insert Code here } } Which of the following code snippets, when substituted to (//Insert Code here) in the above program, will convert the dob from String to Date type?
DateFormat df = new SimpleDateFormat("dd/MM/yyyy");try {Date d = df.parse(dob);} catch(ParseException pe) { }
GregorianCalendar g = new GregorianCalendar(dob);Date d = g.getDate();
Calendar c = new Calendar(dob);Date d = g.getDate();
Date d = new Date(dob);
CalendarFormat cf = newSimpleCalendarFormat("dd/MM/yyyy");try {Date d = cf.parse(dob);} catch(ParseException pe) { }
Submit
4.
Consider the following code: public class WrapIt { public static void main(String[] args) { new WrapIt().testC('a'); } public void testC(char ch) { Integer ss = new Integer(ch); Character cc = new Character(ch); if(ss.equals(cc)) System.out.print("equals "); if(ss.intValue()==cc.charValue()) { System.out.println("EQ"); } } } Which of the following gives the valid output for the above code?
Compile-time error: Wrapper types cannot be comparedusing equals
Compile-time error: Integer wrapper cannot accept char type
Prints: equals
Prints: EQ
Prints: equals EQ
Submit
5.
Consider s1 and s2 are sets. Which of the following options gives the exact meaning of the method call s1.retainAll(s2)?
Transforms s1 into the union of s1 and s2
Transforms s1 into the (asymmetric) set difference of s1 ands2
Transforms s1 into the intersection of s1 and s2.
Copies elements from s2 to s1
Returns true if s2 is a subset of s1
Submit
6.
You need to create a class that implements the Runnable interface to do background image processing. Out of the following list of method declarations, select the method that must satisfy the requirements.
Public void run()
Public void start()
Public void stop()
Public void suspend()
Submit
7.
Consider the following code snippet: String deepak = "Did Deepak see bees? Deepak did."; Which of the following method calls would refer to the letter b in the string referred by the variable deepak?
CharAt(13)
CharAt(15)
CharAt(12)
CharAt(16)
CharAt(14)
Submit
8.
Consider the following code snippet: class TestString3 { public static void main(String args[]) { String s1 = "Hello"; StringBuffer sb = new StringBuffer(s1); sb.reverse(); s1.concat(sb.toString()); System.out.println(s1 + sb + s1.length() + sb.length()); } } What will be the output of the above code snippet?
HelloolleH55
HelloolleH44
HelloHello44
HelloHello33
HelloHello55
Submit
9.
Which of the following are true about inheritance?(Choose 3)
Inheritance enables adding new features and functionality toan existing class without modifying the existing class
In an inheritance hierarchy, a superclass can also act as a subclass
Inheritance is a kind of Encapsulation
Inheritance does not allow sharing data and methods amongmultiple classes
In an inheritance hierarchy, a subclass can also act as a superclass
Submit
10.
Consider the following code snippet: public class Welcome { String title; int value; public Welcome() { title += " Planet"; } public void Welcome() { System.out.println(title + " " + value); } public Welcome(int value) { this.value = value; title = "Welcome"; Welcome(); } public static void main(String args[]) { Welcome t = new Welcome(5); } } Which of the following option will be the output for the above code snippet?
Welcome Planet
The code runs with no output
Compilation fails
Welcome 5
Welcome Planet 5
Submit
11.
Which of the following options gives the relationship between a Pilot class and Plane class?
Inheritance
Polymorphism
Persistence
Aggregation
Association
Submit
12.
Consider the following code snippet: import java.io.*; public class IOCode1 { public static void main(String args[]) throws IOException { BufferedReader br1 = new BufferedReader( new InputStreamReader(System.in)); BufferedWriter br2 = new BufferedWriter( new OutputStreamWriter(System.out)); String line = null; while( (line = br1.readLine()) != null ) { br2.write(line); br2.flush(); } br1.close(); br2.close(); } } What will be the output for the above code snippet?
Reads the text from keyboard and prints the same to theconsole on pressing Ctrl Z, flushes (erases) the same from...
Reads the text from keyboard and prints the same to theconsole on pressing Ctrl Z, flushes (erases) the same from theconsole.
Reads the text from keyboard character by character andprints the same to the console on typing every character.
Reads the text from keyboard line by line and prints the sameto the console on pressing ENTER key at the...
Reads the text from keyboard line by line and prints the sameto the console on pressing ENTER key at the end of every line
Reads the text from keyboard line by line and prints the sameto the console on pressing ENTER key at the...
Reads the text from keyboard line by line and prints the sameto the console on pressing ENTER key at the end of every line,then the same is flushed (erased) from the console.
Reads the text from keyboard and prints the same to theconsole on pressing Ctrl Z
Submit
13.
Both TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE types ResultSets will make changes visible if they are closed and then reopened. State True or False.
True
False
Submit
14.
From JDK 1.6, which of the following interfaces is also implemented by java.util.TreeSet class?
NavigableSet
Deque
NavigableMap
NavigableList
Submit
15.
Which of the following flow control features does Java support? (Choose 2)
Labeled continue
Labeled goto
Labeled throw
Labeled catch
Labeled break
Submit
16.
Consider the following code: public class Key1 { public boolean testAns( String ans, int n ) { boolean rslt; if (ans.equalsIgnoreCase("YES") & n > 5) rslt = true; return rslt; } public static void main(String args[]) { System.out.println(new Key1().testAns("no", 5)); } } Which of the following will be the output of the above program?
Compile-time error
Runtime Error
NO
False
True
Submit
17.
Which of the following statement is true?
To call the join() method, a thread must own the lock of theobject on which the call is to be...
To call the join() method, a thread must own the lock of theobject on which the call is to be made
To call the yield() method, a thread must own the lock of theobject on which the call is to be...
To call the yield() method, a thread must own the lock of theobject on which the call is to be made.
To call the wait() method, a thread must own the lock of theobject on which the call is to be...
To call the wait() method, a thread must own the lock of theobject on which the call is to be made.
To call the wait() method, a thread must own the lock of thecurrent thread.
To call the sleep() method, a thread must own the lock of theobject which the call is to be made.
Submit
18.
Delimiters themselves be considered as tokens. State True or False.
True
False
Submit
19.
Consider the following code: public class ExampleSeven { public static void main(String [] args) { String[] y = new String[1]; String x = "hello"; y[0] = x; // Code here System.out.println("match"); } else { System.out.println("no match"); } } } Which of the following code snippet when substituted at the commented line (// Code here) in the above code will make the program to print "no match"?
If (x != y[0].toString()) {
If (x & y[0]) {
If (x.equals(y[0])) {
If (!x.equals(y[0])) {
Submit
20.
Consider the following code: interface Greek { } class Alpha implements Greek { } class Beta extends Alpha {} class Delta extends Beta { public static void main( String[] args ) { Beta x = new Beta(); // insert code here } } Which of the following code snippet when inserted individual at the commented line (// insert code here), will cause a java.lang.ClassCastException?
Greek f = (Beta)(Alpha)x;
Alpha a = x;
Greek f = (Alpha)x;
Beta b = (Beta)(Alpha)x;
Greek f = (Delta)x;
Submit
21.
Consider the following code: public class Code17 { public static void main(String args[]) { new Code17(); } { System.out.print("Planet "); } { System.out.print("Welcome "); } } Which of the following will be the valid output for the above code?
Welcome Planet
Compilation Error
Compiles and Executes with no output
Planet
Planet Welcome
Submit
22.
Consider the following code: class Alpha { protected Beta b; } class Gamma extends Alpha { } class Beta { } Which of the following statement is True?
Beta has-a Gamma and Gamma is-a Alpha.
Gamma has-a Beta and Gamma is-a Alpha
Alpha is-a Gamma and has-a Beta.
Gamma is-a Beta and has-a Alpha.
Alpha has-a Beta and Alpha is-a Gamma.
Submit
23.
Consider the following scenario: Mr.Ram is working for a Software Company. He needs to save and reload objects from a Java application. For security reasons, the default Sun Microsystem's implementation of saving and loading of Java Objects is not used. He needs to write his own module for the same. Which of the following options can be used to accomplish the above requirement?
Cloneable interface
Serializable interface
Readable interface
Externalizable interface
Writable interface
Submit
24.
Which of the following codes will compile and run properly?
Public class Test2 {static public void main(String[] in) {System.out.println("Test2");}}
Public class Test4 {static int main(String args[]) {System.out.println("Test4");}}
Public class Test1 {public static void main() {System.out.println("Test1");}}
Public class Test3 {public static void main(String args) {System.out.println("Test3");}}
Public class Test5 {static void main(String[] data) {System.out.println("Test5");}}
Submit
25.
Consider the following program: class joy extends Exception { } class smile extends joy { } interface happy { void a() throws smile; void z() throws smile; } class one extends Exception { } class two extends one { } abstract class test { public void a()throws one { } public void b() throws one { } } public class check extends test { public void a() throws smile { System.out.println("welcome"); throw new smile(); } public void b() throws one { throw new two(); } public void z() throws smile { throw new smile(); } public static void main(String args[]) { try { check obj=new check(); obj.b(); obj.a(); obj.z(); } catch(smile s) { System.out.println(s); }catch(two t) { System.out.println(t.getClass()); }catch(one o) { System.out.println(o); }catch(Exception e) { System.out.println(e); } } } What will be the output of the above program?
Welcomeclass two
Throws a compile time exception as overridden method a()does not throw exception smile
Class two
Throws a compile time exception as overridden method z()does not throw exception smile
Two
Submit
26.
Consider the following code: @interface Author { String name(); String date(); } Which of the following is the correct way of implementing the above declared annotation type?
Author(name = "Deepak",date = "02/04/2008")class MyClass() { }
@Author(name = "Deepak",)class MyClass() { }
@Author("Deepak","02/04/2008")class MyClass() { }
SELECT * BULK COLLECT INTO emp_details_t from emp;
@Author(name = "Deepak",date = "02/04/2008")class MyClass() { }
Submit
27.
Consider the following code: public class TestOne { public static void main(String args[]) { byte x = 3; byte y = 5; System.out.print((y%x) + ", "); System.out.println(y == ((y/x) *x +(y%x))); } } Which of the following gives the valid output for above?
Prints: 1, true
Prints 2, false
Prints: 2, true
Prints: 1, false
Submit
28.
Consider the following code snippet: import java.util.*; public class TestCol6 { public static void main(String args[] ){ ArrayList a = new ArrayList(); // Line 1 a.add(new Integer(10)); a.add(new String("Hello")); a.add(new Double(34.9)); } } Which of the following code snippets when replaced at the line marked //Line 1, will make the ArrayList a to accept only Wrapper types of primitive numerics?
ArrayList< Double > a = new ArrayList < Double >();
ArrayList< Integer > a = new ArrayList< Double >();
ArrayList< WrapperType > a = new ArrayList< WrapperType >();
ArrayList< Number > a = new ArrayList< Number >();
ArrayList< Integer > a = new ArrayList< Integer >();
Submit
29.
Consider the following code: public class Code4 { private int second = first; private int first = 1000; public static void main(String args[]) { System.out.println(new Code4().second); } } Which of the following will be the output for the above code?
Throws a Runtime error 'Illegal forward reference'
1000
Compiler complains about forward referencing of membervariables first and second
Compiler complains about private memebers is notaccessible from main() method
Submit
30.
Consider the following code snippet: class Node { Node node; } class NodeChain { public static void main(String a[]) { Node node1 = new Node(); // Line 1 node1.node = node1; // Code here } } Which of the following code snippets when replaced at the comment line (// Code Here) in the above code will make the object created at Line 1, eligible for garbage collection? (Choose 2)
Node1.node = new Node();
Node1 = null;
Node1.node = null;
Node1 = node1.node;
Node1 = new Node();
Submit
31.
Consider the following code: 1. public class Garment { 2. public enum Color { 3. RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff); 4. private final int rgb; 5. Color( int rgb) { this.rgb = rgb; } 6. public int getRGB() { return rgb; } 7. }; 8. public static void main( String[] argv) { 9. // insert code here 10. } 11.} Which of the following code snippets, when inserted independently at line 9, allow the Garment class to compile? (Choose 2)
Color treeColor = Color.GREEN;
Color purple = new Color( 0xff00ff);
Color skyColor = BLUE;
If( RED.getRGB() < BLUE.getRGB() ) {}
If( Color.RED.ordinal() < Color.BLUE.ordinal() ) {}
Submit
32.
The purpose of Soft Reference Type object is ______________.
To automatically delete objects from a container as soonclients stop referencing them
To allow clean up after finalization but before the space isreclaimed
To keep objects alive provided there is enough memory
To keep objects alive only while they are in use (reachable) byclients
Submit
33.
Which of the following are characteristics of Annotations?(Choose 2)
Annotations are not part of a program.
Annotations are predefined classes.
Annotations are data about program.
Annotations are static methods.
Submit
34.
Which of the following methods are defined in Object class? (Choose 3)
ToString()
CompareTo(Object)
HashCode()
Equals(Object)
Run()
Submit
35.
Consider the following code: public class ObParam{ public int b = 20; public static void main(String argv[]){ ObParam o = new ObParam(); methodA(o); } public static void methodA(ObParam a) { a.b++; System.out.println(a.b); methodB(a); System.out.println(a.b); } public void methodB(ObParam b) { b.b--; } } Which of the following gives the correct output for the above code?
Prints: 21 21
Prints: 20 21
Compilation Error: Non-static method methodB() cannot be referenced from static context methodA()
Prints: 20 20
Prints: 21 20
Submit
36.
The following class definitions are in separate files. Note that the Widget and BigWidget classes are in different packages: 1. package conglomo; 2. public class Widget extends Object{ 3. private int myWidth; 4. XXXXXX void setWidth( int n ) { 5. myWidth = n; 6. } 7. } // the following is in a separate file and in separate package 8. package conglomo.widgets; 9. import conglomo.Widget ; 10. public class BigWidget extends Widget { 11. BigWidget() { 12. setWidth( 204 ); 13. } 14. } Which of the following modifiers, used in line 4 instead of XXXXXX, would allow the BigWidget class to access the setWidth method (as in line 12)? (Choose 2)
Default (blank), that is, the method declaration would readvoid setWidth( int n )
Final
Private
Protected
Public
Submit
37.
Consider the following code: public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which of the following implementations use the Shape class correctly? (Choose 2)
Public class Circle extends Shape {private int radius;public void setRadius(int radius) { this.radius = radius; }public int getRadius() { return...
Public class Circle extends Shape {private int radius;public void setRadius(int radius) { this.radius = radius; }public int getRadius() { return radius; }public void draw() {/* code here */}}
Public class Circle extends Shape {private int radius;public void draw();}
Public abstract class Circle extends Shape {private int radius;}
Public class Circle implements Shape {private int radius;}
Public class Circle extends Shape {public int radius;private void draw() {/* code here */}}
Submit
38.
Which of the following statements are true? (Choose 2)
All exceptions are thrown programmatically from the code or API
All exceptions are thrown by JVM
JVM cannot throw user-defined exceptions
JVM thrown exceptions can be thrown programmatically
All RuntimeException are thrown by JVM
Submit
39.
Consider the following code: class Resource { } class UserThread extends Thread { public Resource res; public void run() { try { synchronized(res) { System.out.println("Planet"); res.wait(); Thread.sleep(1000); res.notify(); System.out.println("Earth"); } } catch(InterruptedException e) { } } } public class StartUserThreads { public static void main(String[] args) { Resource r = new Resource(); UserThread ut1 = new UserThread(); ut1.res = r; UserThread ut2 = new UserThread(); ut2.res = r; ut1.start(); ut2.start(); } } Which of the following will give the correct output for the above code?
Runtime Error "IllegalThreadStateException"
Prints the following output 2 times: Planet(waits for 1000 milli seconds)Earth
Compile-time Error
Prints the following output 1 time: Planet(waits for 1000 milli seconds)Earth
Prints the following output:PlanetPlanet(get into long wait. Never ends)
Submit
40.
Consider the following partial listing of the Widget class: 1. class Widget extends Thingee { 2. static private int widgetCount = 0; 3. static synchronized int addWidget() { widgetCount++; 4. return widgetCount; 5. } 6. String wName; 7. public Widget( int mx, String T ) { 8. wName = "I am Widget #" + addWidget(); 9. } 10. // more methods follow 11. } Which of the following gives the significance of the word "private" in line 2?
Since widgetCount is private, only methods in the Widgetclass can access it.
If another class tries to access widgetCount, a runtimeexception will be thrown.
Since widgetCount is private, only the addWidget method canaccess it.
Since widgetCount is private, only methods in the Widgetclass and any derived classes can access it.
Submit
41.
Consider the following program: class CatchableException extends Throwable { } class ThrowableException extends CatchableException { } public class ThrowCatchable { public static void main(String args[]) { try { tryThrowing(); } catch(CatchableException c) { System.out.println("Catchable caught"); } finally { tryCatching(); } } static void tryThrowing() throws CatchableException { try { tryCatching(); throw new ThrowableException(); } catch(NullPointerException re) { throw re; } } static void tryCatching() { System.out.println(null + " pointer exception"); } } What will be the output of the above program?
Null pointer exceptionCatchable caughtnull pointer exception
Runtime error
Catchable caughtnull pointer exceptionnull pointer exception
Compile-time error
Null pointer exceptionnull pointer exceptionCatchable caught
Submit
42.
Consider the following code: class Component { private int param; public void setParam(int param) { this.param = param; } public int getParam() { return param; } } class Container { private Component component; public void setComponent(Component component) { this.component = component; } public Component getComponent() { return component; } } public class TestContainerComponent { public static void main(String args[]) { Container container = new Container(); Component component = new Component(); int j = 10; component.setParam(j); container.setComponent(component); // Insert code here System.out.println(container.getComponent().getParam()); } } Which of the following code snippets when individually repalced at the commented line (// Insert code here) in the above code will produce the output 100? (Choose 3)
Container.setComponent(component); component=newComponent(); component.setParam(100);
Component = new Component(); component.setParam(100);container.setComponent(component);
Component.setParam(100);
Component = new Component(); component.setParam(100);
Container.getComponent().setParam(100);
Submit
43.
Which of the following are true about SQLWarning class in JDBC API?
SQLWarning is the subclass of SQLException
SQLWarning and SQLException can be used interchangeably
SQLWarning affects the normal program execution
SQLWarning messages are accessible through the Statementobject
SQLWarning can be caught and handled using try-catch
Submit
44.
Consider the following scenario: You are writing a set of classes related to cooking and have created your own exception hierarchy derived from java.lang.Exception as follows: Exception +-Bad TasteException +-Bitter Exception +-Sour Excpetion BadTasteException is defined as an abstract class. You have a method eatMe that may throw a BitterException or a SourException. Which of the following method declarations are acceptable to the compiler? (Choose 3)
Public void eatMe() throws BitterException, SourException
Public void eatMe() throws Throwable
Public void eatMe() throw BadTasteException
Public void eatMe() throws BadTasteException
Public void eatMe() throws RuntimeException
Submit
View My Results
Related Quizzes
Which Vocaloid Are You?
Which Vocaloid Are You?
3ds Max Quick Test
3ds Max Quick Test
Mechanical Drafting Exam Solidworks
Mechanical Drafting Exam Solidworks
Tally ERP
Tally ERP
Phone Replacement: Customer Service Trivia Quiz
Phone Replacement: Customer Service Trivia Quiz
Myob Accounting 18
Myob Accounting 18
Thank you for your feedback!
Would you like to edit this question to improve it?
No thanks
Name:
Email:
Oops! Give us more information:
Incorrect Question
Incorrect Answer
Typos
I have a feedback
Submit
Please provide name and email to proceed.
Please provide correct email to proceed.
Please provide feedback.
Please select the option.
All (44)
Unanswered (
)
Answered (
)
Which of the following methods is used to check whether ResultSet...
Consider the following program:...
Consider the following code snippet:...
Consider the following code:...
Consider s1 and s2 are sets....
You need to create a class that implements the Runnable interface to...
Consider the following code snippet:...
Consider the following code snippet:...
Which of the following are true about inheritance?(Choose 3)
Consider the following code snippet:...
Which of the following options gives the relationship between a Pilot...
Consider the following code snippet:...
Both TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE types...
From JDK 1.6, which of the following interfaces is also implemented by...
Which of the following flow control features does Java support?...
Consider the following code:...
Which of the following statement is true?
Delimiters themselves be considered as tokens. State True or False.
Consider the following code:...
Consider the following code:...
Consider the following code:...
Consider the following code:...
Consider the following scenario:...
Which of the following codes will compile and run properly?
Consider the following program:...
Consider the following code:...
Consider the following code:...
Consider the following code snippet:...
Consider the following code:...
Consider the following code snippet:...
Consider the following code:...
The purpose of Soft Reference Type object is ______________.
Which of the following are characteristics of Annotations?(Choose 2)
Which of the following methods are defined in Object class? (Choose 3)
Consider the following code:...
The following class definitions are in separate files. Note that the...
Consider the following code:...
Which of the following statements are true? (Choose 2)
Consider the following code:...
Consider the following partial listing of the Widget class:...
Consider the following program:...
Consider the following code:...
Which of the following are true about SQLWarning class in JDBC API?
Consider the following scenario:...
X
OK
X
OK
Cancel
X
OK
Cancel
Back to top
Back to top
Advertisement