Quizzes
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
›
Language
›
Slovenian
Dd5
45 Questions
|
By Unrealvicky | Updated: Jul 30, 2011
| Attempts: 573
Share
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
/ 46
🏆
Rank #--
▾
0 %
0/100
Score
0/100
1.
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 intersection of s1 and s2.
Copies elements from s2 to s1
Returns true if s2 is a subset of s1
Submit
Start Quiz
About This Quiz
2.
What first name or nickname would you like us to use?
You may optionally provide this to label your report, leaderboard, or certificate.
2.
Which of the following is the process of creating a new class from an existing class?
Polymorphism
Inheritance
Abstraction
Reusability
Submit
3.
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?
Prints: EQ
Prints: equals
Compile-time error: Wrapper types cannot be compared using equals
Prints: equals EQ
Compile-time error: Integer wrapper cannot accept char type
Submit
4.
Consider the following code: class One { public One() { System.out.print(1); } } class Two extends One { public Two() { System.out.print(2); } } class Three extends Two { public Three() { System.out.print(3); } } public class Numbers { public static void main(String[] argv) { new Three(); } } Which of the following will be the output for the above program?
3
No output
321
32
123
Submit
5.
Consider the following code: 1. public class GetArray2 { 2. public static void main(String [] args) { 3. int [][] holdit = new int[6][]; 4. for(int x = 0;x<6;x++) { 5. holdit[x] = new int[3]; 6. holdit[x][0] = (x + 0); 7. holdit[x][1] = (x + 1); 8. holdit[x][2] = (x + 2); 9. System.out.println(holdit[x][0]+" "+holdit[x][1]+" "+holdit[x][2]); 10. } 11. } 12. } Which of the following gives the valid output for above?
Compilation fails because of an error on line 5
Compilation succeeds and the program prints: 0 1 2 1 2 3 2 3 4 3 4 5 4 5...
Compilation succeeds and the program prints: 0 1 2 1 2 3 2 3 4 3 4 5 4 5 6 5 6 7
Compilation fails because of an error on line 3
Compilation succeeds and the program prints: 1 1 1 2 2 2 3 3 3 4 4 4 5 5...
Compilation succeeds and the program prints: 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6
Submit
6.
Consider the following code snippet: public class TestString10{ public void print() { String s = "Hello"; StringBuffer sb = new StringBuffer("Hello"); concatinateStrings(s, sb); System.out.println(s+" "+sb); } public void concatinateStrings(String str, StringBuffer strBuff){ StringBuffer sk = strBuff; str = str + " world"; sk.append(" world"); } public static void main (String[] args) { TestString10 t = new TestString10(); t.print(); } } What will be the output of the above code snippet?
Hello Hello Hello
World Hello Hello
Hello Hello world
Hello world Hello
World world world
Submit
7.
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 character by character and prints the same to the console on typing every character.
Reads the text from keyboard and prints the same to the console on pressing Ctrl Z, flushes (erases) the same...
Reads the text from keyboard and prints the same to the console on pressing Ctrl Z, flushes (erases) the same from the console.
Reads the text from keyboard line by line and prints the same to the console on pressing ENTER key at...
Reads the text from keyboard line by line and prints the same to the console on pressing ENTER key at the end of every line
Reads the text from keyboard and prints the same to the console on pressing Ctrl Z
Reads the text from keyboard line by line and prints the same to the console on pressing ENTER key at...
Reads the text from keyboard line by line and prints the same to the console on pressing ENTER key at the end of every line, then the same is flushed (erased) from the console.
Submit
8.
What of the following is the default Scroll type for a ResultSet object?
ResultSet.TYPE_SCROLL_SENSITIVE
ResultSet.TYPE_SCROLLABLE
ResultSet.TYPE_SCROLL_INSENSITIVE
ResultSet.TYPE_FORWARD_ONLY
ResultSet.TYPE_SCROLL_BIDIRECTIONAL
Submit
9.
Consider the following partial code: public class CreditCard { private String cardID; private Integer limit; public String ownerName; public void setCardInformation(String cardID, String ownerName, Integer limit) { this.cardID = cardID; this.ownerName = ownerName; this.limit = limit; } } Which of the following statement is True regarding the above given code?
The class is fully encapsulated
The ownerName variable breaks encapsulation
The setCardInformation method breaks encapsulation
The cardID and limit variables break polymorphism
The code demonstrates polymorphism
Submit
10.
Which of the following types of driver provides maximum decoupling between database and Java application?
Type IV driver
Type II driver
Type I driver
Type III driver
Submit
11.
Which of the following statements are true about String Arrays? (Choose 2)
Array index can be a negative value
String[][] s;
Array decaration: String[6] strarray;
String[][] s = new String[5][];
Array index can be a long value
Submit
12.
Consider the following program: import java.io.*; public class SteppedTryCatch { public static void main(String[] args) { try { try { try { // Line 1 } catch(Exception e3) { System.out.println("Exception 1"); // Line 2 } } catch(IOException e2) { System.out.println("Exception 2"); // Line 3 } } catch(FileNotFoundException e1) { System.out.println("Exception 3"); } } } You need to make the above program to print the output as Exception 1 Exception 2 Exception 3 Which of the following when substituted in place of commented lines (// Line 1, Line 2 and Line 3) produce the desired output?
Line 1 : throw new IOException(); Line 2 : throw new FileNotFoundException(); Line 3 : throw new Exception();
Line 1 : throw new Exception(); Line 2 : throw new IOException(); Line 3 : throw new FileNotFoundException();
The code is wrong. Exceptions should be caught in reversed hierarchy order.
Line 1 : throw new IOException(); Line 2 : throw new IOException(); Line 3 : throw new IOException();
Line 1 : throw new FileNotFoundException(); Line 2 : throw new IOException(); Line 3 : throw new Exception();
Submit
13.
Consider the following code snippet: import java.util.*; public class TestCol3 { public static void main(String[] args) { List l = new ArrayList(); l.add("One"); l.add("Two"); l.add("Three"); l.add("Four"); l.add("One"); l.add("Four"); Set h = new HashSet(); h.addAll(l); System.out.println("Size:" + l.size() + h.size()); } } What will be the output of the following code snippet?
Size: 64
Size: 44
Size: 66
Compilation error
Size: 46
Submit
14.
Consider the following code snippets: class GC2 { public GC2 getIt(GC2 gc2) { return gc2; } public static void main(String a[]) { GC2 g = GC2(); GC2 c = GC2(); c = g.getIt(c); } } How many objects are eligible for Garbage Collection?
Two
None of the objects are eligible
Three
Four
One
Submit
15.
Consider the following code: class Planet { } class Earth extends Planet { } public class WelcomePlanet { public static void welcomePlanet(Planet planet) { if (planet instanceof Earth) { System.out.println("Welcome!"); } else if (planet instanceof Planet) { System.out.println("Planet!"); } else { System.exit(0); } } public static void main(String args[]) { WelcomePlanet wp = new WelcomePlanet(); Planet planet = new Earth(); welcomePlanet(planet); } } Which of the following will be the output of the above program?
The code runs with no output
Compilation fails
Welcome!
Planet!
An exception is thrown at runtime
Submit
16.
A monitor called 'mon' has 5 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thread1. How can you notify thread1 so that it alone moves from Waiting state to Ready State?
Execute mon.notify(thread1); from synchronized code of any object
Execute notify(thread1); from within synchronized code of mon
You cannot specify which thread will get notified
Execute thread1.notify(); from synchronized code of any object
Execute thread1.notify(); from any code(synchronized or not) of any object
Submit
17.
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[Integer] a = new ArrayList[Integer]();
ArrayList[WrapperType] a = new ArrayList[WrapperType]();
ArrayList[Integer] a = new ArrayList[Double]();
ArrayList[Double] a = new ArrayList[Double]();
ArrayList[Number] a = new ArrayList[Number]();
Submit
18.
Consider the following: Class A contains the following: i. Instance Block ii. main() method iii. Static Block iv. Default Constructor of A Assume an instance of class A is created in the main() method. Which of the following gives the correct sequence of execution of above mentioned elements?
Iii, ii, i, iv
Iii, i, ii, iv
Ii, i, iv, iii
I, iv, iii, ii
Iv, iii, ii, i
Submit
19.
Which of the following options are true about Associations?(choose 2)
Association refers to a class reuses the properties and methods of another class
Association refers to an object composed of set of other objects
Association refers to binding of related data and behaviours into a single entity
Associations are bi-directional
In Associations, cardinality refers to the number of related objects
Submit
20.
Consider the following code: public class Pass { static int j=20; public static void main(String argv[]) { int i=10; Pass p = new Pass(); p.amethod(i); System.out.println(i); System.out.println(j); } public void amethod(int x) { x=x*2; j=j*2; } } Which of the following gives the correct output for the above code?
Prints: 10, 40
Prints: 20, 40
Compile time Error: Method parameter does not match variable
Prints: 10,20
Submit
21.
To which of the following elements, annotations can be applied? (Choose 3)
Classes
Fields
Jar files
Class files
Methods
Submit
22.
Which of the following gives the correct sequence of execution of callback methods in a JUnit TestCase?
1. setUp() method 2. testXXX() method 3. tearDown() method Above sequence is for every testXXX() method in the TestCase
1. setUp() method 2. tearDown() method 3. All testXXX() methods
1. All testXXX() methods 2. setUp() method 3. tearDown() method
1. setUp() method 2. All testXXX() methods 3. tearDown() method
Submit
23.
Consider the following program: 1. class CheckedException extends RuntimeException { } 2. class UncheckedException extends Exception { } 3. public class Check { 4. public static void main(String args[]) { 5. generateException1(); 6. generateException2(); 7. } 8. 9. private static void generateException1() { 10. throw new CheckedException(); 11. } 12. 13. private static void generateException2() { 14. throw new UncheckedException(); 15. } 16. } Which of the following is true regarding the above given program?
No compilation error but throws RuntimeException on running the code
Compilation error at line 10
Compilation error at line 14
Compilation error at line 5
Compilation error at line 6
Submit
24.
Which of the following pre-defined annotations requires that an annotation type should itself annotate with, in order to make the information in an user- defined annotation type appear in Javadoc-generated documentation?
@Override
@Documented
@Comment
@Deprecated
Submit
25.
State which of the following are default delimiters?(Choose 3)
Form feed character
Tab character
The dollar character
Space character
The underscore character
Submit
26.
Consider there are two threads, "Thread A" and "Thread B". "Thread A" holds a lock on "Object X". "Thread B" is blocked inside a wait call on Object X. Which of the following will make the "Thread B" runnable?
Thread A's wait() times out.
Thread A releases the lock on B by calling the notifyAll()
Thread A is interrupted.
Thread B is interrupted.
Thread B releases the lock on object X and calls the notify() method on thread
Submit
27.
Which of the following statements are true? (choose 2)
An object becomes eligible for garbage collection when all references denoting it are set to null
The automatic garbage collection of the JVM prevents programs from ever running out of memory
A program can suggest that garbage collection be performed but not force it
None of the listed options
Garbage collection is platform independent
Submit
28.
Consider the following code: public class Code9 { public static void main(String args[]) { System.out.println(Math.abs(Integer.MIN_VALUE)); } } Which of the following will be the output for the above given program? (Choose 2)
Compilation Error
Compiles successfully and prints a value which is less than zero
Compiles successfully and prints a value which is equal to Integer.MIN_VALUE
Compiles successfully and prints a value which is equal to -Integer.MAX_VALUE
Compiles successfully and prints a value which is equal to Integer.MIN_VALUE + 1
Submit
29.
Consider the following code: package com.java.test; public class A { public void m1() {System.out.print("A.m1, ");} protected void m2() {System.out.print("A.m2, ");} private void m3() {System.out.print("A.m3, ");} void m4() {System.out.print("A.m4, ");} } class B { public static void main(String[] args) { A a = new A(); a.m1(); // 1 a.m2(); // 2 a.m3(); // 3 a.m4(); // 4 } } Assume that both of the above classes are stored in a single source file called 'A.java'. Which of the following gives the valid output of the above code?
Prints: A.m1, A.m2, A.m3, A.m4,
Compile-time error at 4.
Compile-time error at 3.
Compile-time error at 2.
Compile-time error at 1.
Submit
30.
Consider the following program: class TestThread extends Thread { public static void main(String apps[]) { Thread t = null; TestThread tc = new TestThread(); for (int i =0;i<5;i++) { t = new Thread(tc); // Insert Code Here } } public void run() { System.out.println("Hello"); } } Which of the following code when substituted to the commented line (//Insert Code) will make the program to execute properly?
T.join()
T.start()
No additional code required
T.run()
T.sleep(1000)
Submit
31.
Consider the following code: package test; class Target { String name = "hello"; } Which of the following options are valid that can directly access and change the value of the variable 'name' in the above code? (Choose 2)
Any class in the test package
Any class that extends Target outside the test package
Any class
Only the Target class
Any class that extends Target within the test package
Submit
32.
Consider the following code segment: public class ExampleThree { public static void main(String args[]) { int i = 1; // Line 1 short s = 1; // Line 2 long l = 1; // Line 3 i = l + i; // Line 4 l = s + i; // Line 5 } } Which of the following gives the line in the above program that will result in error?
Line 4
Line 7
Line 6
Line 3
Line 5
Submit
33.
Consider the following scenario: An application needs to write a log file on the sequence of actions it takes while running. Which of the following stream classes can be used to implement the above requirement?
FileOutputStream
LogWriter
PrintWriter
OutputStream
Writer
Submit
34.
Consider the following code: class TM { public static void main(String a[]) { System.out.println(a[0]+a[0].length()+a.length); } } Select the valid inputs and outputs. (Choose 2)
Input : java TM "Trick1"+"Trick2" "Trick3" Output: Trick1+Trick2132
Input : java TM 'J2SE', 'J2EE', 'J2ME' Output: J2SE43
Input : java TM 123+456 "abc" "Tricky" Output: 57933
Input : java TM 'This is really tricky' Output: This is really tricky211
Input : java TM "123", abc+234 Output: 123,42
Submit
35.
Consider the following code: public class TH2 { public static synchronized void main(String[] args) throws InterruptedException { Thread t = new Thread(); t.start(); System.out.print("keep"); t.wait(10000); System.out.print("Smiling"); } } Which of the following gives the valid ouptut for the above code?
It prints keepSmiling with a 10000-second delay between keep and Smiling.
It prints keepSmiling with a 10-second delay between keep and Smiling
An exception is thrown at runtime
It prints keep and never exits
It prints keepSmiling and exits almost immeditately
Submit
36.
Which of the following statements is true about NavigableSet interface?
A SortedSet extended with navigation methods for Maps.
A SortedSet extended with navigation methods for Lists.
A new class implementation of Set which can navigate the ResultSet object
A SortedSet extended with navigation methods reporting closest matches for given search targets.
Submit
37.
Consider the following code: 1. public class Boxer1{ 2. Integer i; 3. int x; 4. 5. public Boxer1(int y) { 6. x = i+y; 7. System.out.println(x); 8. } 9. 10. public static void main(String[] args) { 11. new Boxer1(new Integer(4)); 12. } 13. } Which of the following will be the output of the above program?
Compilation fails because of an error in line 11
A NullPointerException occurs at runtime
Prints: 4
A NumberFormatException occurs at runtime
Submit
38.
Which of the following options are true? (Choose 2)
Error objects are thrown only by JVM
Errors can be thrown programmatically
A class can extend Error class and can be used as user-defined Error class
Errors are handled only by JVM
Errors cannot be handled programmatically using try-catch blocks.
Submit
39.
Consider the following code: public class ThrowsException { static void throwMethod() { System.out.println("Inside throwMethod."); throw new IllegalAccessException("exception"); } public static void main(String args[]) { try { throwMethod(); } catch (IllegalAccessException e) { System.out.println("Caught " + e); } } } Which of the following gives the output for the above given code?
Compiles successfully, nothing is printed
Compilation Error
Runtime Error
D. Inside showMethod. followed by caught: java.lang.IllegalAccessException: exception
Submit
40.
Which of the following options give the names of the data structures that can be used for Range-View operations, but no nulls?(choose 2)
SortedSet
List
Map
Vector
Submit
41.
Which of the following classes is used to handle the abnormal situation that may occur during database calls using JDBC API?
SQLException
Driver
Connection
DriverManager
Statement
Submit
42.
Consider the following code snippet: interface InterfaceOne { int ID = 10; int getAccess(); } interface InterfaceTwo { int ID = 20; int getAccess(); } class InterfaceImpl implements InterfaceOne, InterfaceTwo { public int getAccess() { if (this instanceof InterfaceOne) { return InterfaceOne.ID; } else { return InterfaceTwo.ID; } } } public class Code { public static void main(String args[]) { InterfaceOne i1 = new InterfaceImpl(); System.out.println(i1.getAccess()); InterfaceTwo i2 = (InterfaceTwo) i1; System.out.println(i2.getAccess()); } } Which of the following will be the output for the above code snippet?
10 10
10 20
Compile time error. Incompatible Type conversion.
20 10
20 20
Submit
43.
Consider the following code: class A is defined in packageone as follows: package com.packageone; public class A { private int x; public A(int x) { this(); this.x = x; } abstract void print(); } And class B is defined in packagetwo as follows: package com.packagetwo; import com.packageone.A; class B extends A { B(int x) { super(x); } void print() { System.out.println(x); } } class C { public static void main(String args[]) { A a = new B(10); } } Which of the following changes will make the code to run properly? (Choose 3)
Class B should be declared public abstract
Class A should be declared public abstract
The print method in class B should refer the x as super.x
The member x in class A should be declared as protected
This() method call should be removed from the class A constructor
Submit
44.
Which of the following statements are true regarding equals() method?(Choose 3)
Defined in the Object class
Essential for inheriting a class
Used for object's content comparison
It is polymorphic
Declared in the Object class
Submit
45.
Consider the following code snippet: public class Demo extends Object { String Title; public Demo( String t ){ Title = t; } public void showTitle() { System.out.println( "Title is " + Title ); } } class DerivedDemo extends Demo { public void setTitle( String tt ) { Title = tt ; } } public class TasteIt { public static void main(String args[]) { DerivedDemo dd = new DerivedDemo(); dd.showTitle(); Which of the following option will be the output for the above code snippet?
Prints: "Title is null" to standard output.
A NullPointerException is thrown at Runtime
A ClassCastException is thrown at Runtime
Compilation Error
Submit
×
Thank you for your feedback!
View My Results
Related Quizzes
Odbojka - Sodniški Znaki
Odbojka - sodniški znaki
Kateri Poklic Je Pravi?
KATERI POKLIC JE PRAVI?
Tehnika In Tehnologija, 6. Razred
TEHNIKA IN TEHNOLOGIJA, 6. RAZRED
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 (45)
Unanswered (
)
Answered (
)
Consider s1 and s2 are sets....
Which of the following is the process of creating a new class from an...
Consider the following code:...
Consider the following code:...
Consider the following code:...
Consider the following code snippet:...
Consider the following code snippet:...
What of the following is the default Scroll type for a ResultSet...
Consider the following partial code:...
Which of the following types of driver provides maximum decoupling...
Which of the following statements are true about String Arrays?...
Consider the following program:...
Consider the following code snippet:...
Consider the following code snippets:...
Consider the following code:...
A monitor called 'mon' has 5 threads in its waiting pool; all...
Consider the following code snippet:...
Consider the following:...
Which of the following options are true about Associations?(choose 2)
Consider the following code:...
To which of the following elements, annotations can be applied?...
Which of the following gives the correct sequence of execution of...
Consider the following program:...
Which of the following pre-defined annotations requires that an...
State which of the following are default delimiters?(Choose 3)
Consider there are two threads, "Thread A" and "Thread...
Which of the following statements are true? (choose 2)
Consider the following code:...
Consider the following code:...
Consider the following program:...
Consider the following code:...
Consider the following code segment:...
Consider the following scenario:...
Consider the following code:...
Consider the following code:...
Which of the following statements is true about NavigableSet...
Consider the following code:...
Which of the following options are true? (Choose 2)
Consider the following code:...
Which of the following options give the names of the data structures...
Which of the following classes is used to handle the abnormal...
Consider the following code snippet:...
Consider the following code:...
Which of the following statements are true regarding equals()...
Consider the following code snippet:...
X
OK
X
OK
Cancel
X
OK
Cancel
Your Rank: #-- / --
Leaderboard
✕