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
›
Language
›
Slovenian
Dd2
45 Questions
|
By Unrealvicky | Updated: Jul 30, 2011
| Attempts: 800
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
/ 45
0 %
0/100
Score
0/100
1.
Consider the following code snippet: abstract class Director { protected String name; Director(String name) { this.name = name; } abstract void occupation(); } class FilmDirector extends Director { FilmDirector(String name) { super(name); } void occupation() { System.out.println("Director " + name + " directs films"); } } public class TestDirector { public static void main(String[] args) { FilmDirector fd = new FilmDirector("Manirathnam"); fd.occupation(); new Director("Manirathnam") { void occupation() { System.out.println("Director " + name + " also produces films"); } }.occupation(); } } Which of the following will be the output of the above code snippet?
Prints: Director Manirathnam also produces films
Compilation fails at TestDirector class
Prints: Director Manirathnam directs films
Runtime Error
Prints: Director Manirathnam directs filmsDirector Manirathnam also produces films
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 code snippet: class TestString2 { public static void main(String args[]) { String s1 = "Test1"; String s2 = "Test2"; s1.concat(s2); System.out.println(""+s1.charAt(s1.length() - 3) + s1.indexOf(s2)); } } What will be the output of the above code snippet?
S5
S-1
T4
15
T4
Submit
3.
Consider the following program: public class Exp4 { static String s = "smile!.."; public static void main(String[] args) { new Exp4().s1(); System.out.println(s); } void s1() { try { s2(); } catch (Exception e) { s += "morning"; } } void s2() throws Exception { s3(); s += "evening"; s3(); s += "good"; } void s3() throws Exception { throw new Exception(); } } What will be the output of the above program?
Smile!..eveningmorning
Smile!..morningevening
Smile!..morning
Smile!..morningeveninggood
Smile!..
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?
No output
123
321
32
3
Submit
5.
Which of the following options gives the difference between == operator and equals() method?
Equals compares hash value and == compares charactersequence
No difference;they are essentially the same
If equals() is true then == is also true
==compares object's memory address but equals charactersequence
== works on numbers equals() works on characters
Submit
6.
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: T1T1T1
Prints: T1T1T3
Submit
7.
Which of the following gives the set of Annotations declared in java.lang package?
@Retention, @Target
@Deprecated, @Override, @SuppressWarning
@Comment, @Class
@Documented, @Inherited
Submit
8.
Consider the following code: class ExampleFive { public static void main(String[] args) { final int i = 22; byte b = i; System.out.println(i + ", " + b); } } Which of the following gives the valid output for the above code?
Prints: 22, 20
Runtime Error: Cannot type cast int to byte
Prints: 22, 22
Compile Time Error: Loss of precision
Submit
9.
Which of the following are true about inheritance?(Choose 3)
In an inheritance hierarchy, a subclass can also act as a superclass
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
Submit
10.
Which of the following options gives the relationship between a Spreadsheet Object and Cell Objects?
Polymorphism
Association
Aggregation
Inheritance
Persistence
Submit
11.
Consider the following program: public class D extends Thread { public void run() { System.out.println("Before start method"); this.stop(); System.out.println("After stop method"); } public static void main(String[] args) { D a = new D(); a.start(); } } What will be the output of the above program?
'Before start method' and 'After stop method'
Compilation error
'Before start method' only
Runtime exception
Submit
12.
Consider the following scenario: A Java application needs to stream a video from a movie file. Which of the following options gives the correct combination of stream classes that can be used to implement the above requirement?
LineInputStream and BufferedInputStream
FileReader and BufferedReader
InputStreamReader and FileInputStream
FileInputStream and FilterInputStream
FileInputStream and BufferedInputStream
Submit
13.
Which of the following is the best-performing implementation of Set interface?
HashSet
TreeSet
Hashtable
LinkedHashSet
SortedSet
Submit
14.
Which of the following are correct regarding HashCode?(Choose 2)
The numeric key is unique
It improves performance
It is a 32 bit numeric digest key
HashCode() value cannot be a zero-value
HashCode() is defined in String class
Submit
15.
Which of the following class in java.sql package maps the SQL data types to Java datatypes?
No explicit data type mapping. Automatically mapped onQuery Call.
JDBCTypes
Types
JDBCSQLTypes
SQLTypes
Submit
16.
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?
Compilation fails
Welcome Planet 5
Welcome 5
Welcome Planet
The code runs with no output
Submit
17.
Which of the following ways can be used to access the String value in the first column of a ResultSet? (Assume rs is the ResultSet object)
Rs.getString(1);
Rs.getString("one");
None of listed options
Rs.getString("first");
Rs.getString(0);
Submit
18.
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 anyobject
Execute thread1.notify(); from any code(synchronized or not)of any object
Execute thread1.notify(); from synchronized code of anyobject
Execute notify(thread1); from within synchronized code ofmon
You cannot specify which thread will get notified
Submit
19.
Consider the following code: public class Choco { Choco() { System.out.print("Choco"); } class Bar { Bar() { System.out.print("bar"); } public void go() { System.out.print("sweet"); } } public static void main(String[] args) { Choco c = new Choco(); c.makeBar(); } void makeBar(){ // Insert code here } } Which of the following code snippet when substituted individually to the above commented line (// Insert code here) will give the following output? Chocobarsweet
New Choco().go();
New Bar().go();
New Choco(). new Bar().go();
(new Bar() {}).go();
Go();
Submit
20.
Consider the following code snippet: class Lock1 { Lock1() { } Lock1(Lock2 lock2) { this.lock2 = lock2; } Lock2 lock2; } class Lock2 { Lock2() { } Lock2(Lock1 lock1) { this.lock1 = lock1; } Lock1 lock1; } class GC6 { public static void main(String args[]) { Lock1 l1 = new Lock1(); Lock2 l2 = new Lock2(l1); l1.lock2 = l2; } } Which of the objects are eligible for garbage collection in the above code?
None of the objects eligible
Lock1
Lock2
L1
L2
Submit
21.
To which of the following elements, annotations can be applied? (Choose 3)
Fields
Jar files
Classes
Methods
Class files
Submit
22.
Which of the following is true about finalize() method?
The finalize() method is guaranteed to run once and onlyonce before the garbage collector deletes an object
Finalize() is called when an object becomes eligible forgarbage collection
An object can be uneligibilize for GC from within finalize()
Calling finalize() method will make the object eligible forGarbage Collection
Finalize() method can be overloaded
Submit
23.
Which of the following options will protect the underlying collections from getting modified?
UnmodifiableCollection(Collection
Collections.checked
SynchronizedCollection(Collection c);
None of the listed options
Submit
24.
Which of the following options give the names of data structures that can be used for elements that have ordering, but no duplicates? (Choose 2)
ArrayList
List
TreeSet
Set
SortedSet
Submit
25.
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
Any class that extends Target within the test package
Any class that extends Target outside the test package
Only the Target class
Any class in the test package
Submit
26.
Which of the following classes is new to JDK 1.6?
Java.io.File
Java.io.Serializable
Java.io.FileFilter
Java.io.Console
Java.io.Externalizable
Submit
27.
Consider the following code snippet: class Train { String name = "Shatapdhi"; } class TestTrain { public static void main(String a[]) { Train t = new Train(); System.out.println(t); // Line a System.out.println(t.toString()); // Line b } } Which of the following statements are true?(Choose 3)
Line a prints the corresponding classname with Object'shashcode in Hexadecimal
Both Line a and Line b prints "Shatapdhi"
Both Line a and Line b will print the corresponding classnamewith Object's hashcode in Hexa Decimal
Output of Line a and Line b will be different
Output of Line a and Line b will be same
Submit
28.
Consider the following code: 1. public class SwitchIt { 2. public static void main(String[] args) { 3. int w1 = 1; 4. int w2 = 2; 5. System.out.println(getW1W2(w1, w2)); 6. } 7. 8. public static int getW1W2(int x, int y) { 9. switch (x) { 10. case 1: x = x + y; 11. case 2: x = x + y; 12. } 13. return x; 14. } 15. } Which of the following gives the valid output of above code?
Compilation succeeds and the program prints "5"
Compilation fails because of an error on line 9
Compilation succeeds and the program prints "3"
Compilation fails because of errors on lines 10 and 11
Submit
29.
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 start()
Public void run()
Public void stop()
Public void suspend()
Submit
30.
The return value of execute() method in Statement interface is __________________.
Array of int
Boolean
ResultSet
Array of ResultSet
Int value
Submit
31.
Consider the following code: public class SwitchIt { public static void main(String args[]) { int x = 10; switch(x) { case 10: for(int i=0; i break; case 20: System.out.println(x); break; case 30: System.out.println(x*2); break; default: System.out.println(x*3); } } } Which of the following will be the output for the above program?
No output
10
11
30
Submit
32.
Which of the following are the valid ways of conversion from Wrapper type to primitive type? (Choose 3)
New Boolean("true").intValue();
New Double(24.5d).byteValue();
New Integer(1).booleanValue();
New Float(100).intValue();
New Integer(100).intValue();
Submit
33.
Consider the following scenario: Here is part of the hierarchy of exceptions that may be thrown during file IO operations: Exception +-IOException +-File Not Found Exception You have a method X that is supposed to open a file by name and read data from it. Given that X does not have any try-catch statements, which of the following option is true?
The method X must be declared as throwingFileNotFoundException
Any method calling X must use try-catch, specifically catchingFileNotFoundException
The method X must be declared as throwing IOException orException
No special precautions need be taken
Submit
34.
At which of the following given situations, unit tests are required to be run on the modules?(Choose 3)
When the modules are deployed to the server
When the other methods, referred in a method in a moduleis modified
When class members are modified
When a method in a module is completed or modified
When the modules are compiled
Submit
35.
Consider the following code: 1 public class A { 2 public void m1() {System.out.print("A.m1, ");} 3 protected void m2() {System.out.print("A.m2, ");} 4 private void m3() {System.out.print("A.m3, ");} 5 void m4() {System.out.print("A.m4, ");} 6 7 public static void main(String[] args) { 8 A a = new A(); 9 a.m1(); 10 a.m2(); 11 a.m3(); 12 a.m4(); 13 } 14 } Which of the following gives the lines that need to be removed in order to compile and run the above code correctly?
Lines 10, 11
No need to comment any line. Will compile and run
Lines 10, 11 and 12
Line 11
Submit
36.
Which of the following statements are correct regarding Static Blocks?(Choose 3)
A class that have static block, should have the main() methoddefined in it
A class can have more than one static block
Static blocks are executed only once
Static blocks are executed before main() method
A static block can call other methods in a class
Submit
37.
Consider the following code snippet: interface i1 { int i = 0; } interface i2 { int i = 0; } class inter implements i1, i2 { public static void main(String[] a) { System.out.println(i); } } Which of the following options will be the output of the above code snippet?
No output
Prints: 0
Runtime Error
Compilation Error
Submit
38.
Consider the following program: public class TryIt { public static void main(String args[]) { try { int i = 0; try { i = 100 / i; } catch(Error e) { System.out.println("Divide by Zero error"); } System.out.println("Error Handled"); } catch(Exception e) { System.out.println("Unexpected exception caught"); } } } What will be the output of the above program?
Divide by Zero errorError HandledUnexpected exception caught
Program compiles and runs without any output
Divide by Zero errorError Handled
Unexpected exception caught
Error HandledUnexpected exception caught
Submit
39.
Consider the following code: class A { } class B extends A { } public class Code2 { public void method(A a) { System.out.println("A"); } public void method(B b) { System.out.println("B"); } public static void main(String args[]) { new Code2().method(new Object()); } } Which of the following will be the output for the above code?
Prints: B
Throws ClassCastException at runtime
Compilation Error 'Cannot find the symbol'
Prints: A
Submit
40.
Consider the following code: 1. class ExampleSix { 2. String msg = "Type is "; 3. public void showType(int n) { 4. String tmp; 5. if(n > 0) tmp = "positive"; 6. System.out.println(msg + tmp); 7. } 8. } On running the above code it throws the compile-time error- the variable tmp is not initialised. Which of the following changes to the above code will make the code to compile properly? (Choose 3)
Delcare the variable tmp as StringBuffer type
Declare the variable tmp as static
Insert the following line at line 6else tmp = "not positive";
Change line 4 as followsString tmp = null;
Remove line 4 and insert it at line 2
Submit
41.
Which of the following actions include the external library required by Java application at runtime in order to run properly? (choose 2)
Compressing the class into zip files and converting it intoexecutable modules, and then packaging it into a jar file
Adding the folder name or jar filename to the CLASSPATHvariable, where the class files of the library exists
Running the application with the following switchesjava -cp ApplicationClassNamejava -classpath ApplicationClassName
Cannot refer to an external libarary, it should be includedbefore the application is packaged.
Pointing the system's PATH variable to the folder or the jarfilename where the class files of the library exists
Submit
42.
Consider the following code snippet: import java.io.*; class Student { private String studentID; private String studentName; public Student() { } public Student(String studentID, String studentName) { this.studentID = studentID; this.studentName = studentName; } public String toString() { return "Student ID : " + studentID + " " + "Student Name : " + studentName; } } public class IOCode3 { public static void main(String args[]) throws FileNotFoundException, IOException { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("C:/ObjectData")); // Line 1 out.writeObject(new Student("100", "Student One")); // Line 2 out.close(); } } What will be the output of the above code snippet?
Code will compile and execute without any error
Throws IOException at // Line 1
Throws IOException at // Line 2
Throws NotSerializableException at // Line 2
Throws NotSerializableException at // Line 1
Submit
43.
Consider the following program: class RE { public static void main(String args[]) { try { String s = null; System.out.println(s.length()); } catch(NullPointerException npe) { System.out.println("NullPointerException handled"); throw new Exception(npe.getMessage()); } } } What will be the output of the above program?
Code compiles and on running creates and throws Exceptiontype object
Code compiles but run without any output
Code does not complile
Code compiles and on running it prints "NullPointerExceptionhandled" then creates and throws Exception type object
Submit
44.
Consider the following code snippet: class Student { String studentID; String studentName; double score; } The instances of the above defined class holds the information of individual student. These details needs to be maintained in a data structure, that * allows searching of student details using studentID * ascending order of Student objects based on studentID Which of the following collection classes can be used to implement the above scenario?
TreeSet
HashMap
HashSet
ArrayList
TreeMap
Submit
45.
Consider the following code: class ABC { public void method1() { DEF def = new DEF(); def.method2(); } } class DEF { public XYZ xyz; public String method2() { return xyz.method3(); } } class XYZ { public String value; public String method3() { value = "XYZ"; return value; } } class TestCode { public static void main(String args[]) { ABC abc = new ABC(); abc.method1(); } } Which of the following will be the output if the above code is compiled and executed?
An exception is thrown at runtime
Prints: XYZ
Compilation fails
Prints: DEF
Prints: ABC
Submit
View My Results
Related Quizzes
Odbojka - Sodniški Znaki
Odbojka - sodniški znaki
Kateri Poklic Je Pravi?
KATERI POKLIC JE PRAVI?
Tehnika In Tehnologija, 7. Razred
TEHNIKA IN TEHNOLOGIJA, 7. 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 the following code snippet:...
Consider the following code snippet:...
Consider the following program:...
Consider the following code:...
Which of the following options gives the difference between ==...
Consider the following program:...
Which of the following gives the set of Annotations declared in...
Consider the following code:...
Which of the following are true about inheritance?(Choose 3)
Which of the following options gives the relationship between a...
Consider the following program:...
Consider the following scenario:...
Which of the following is the best-performing implementation of Set...
Which of the following are correct regarding HashCode?(Choose 2)
Which of the following class in java.sql package maps the SQL data...
Consider the following code snippet:...
Which of the following ways can be used to access the String value in...
A monitor called 'mon' has 5 threads in its waiting pool; all...
Consider the following code:...
Consider the following code snippet:...
To which of the following elements, annotations can be applied?...
Which of the following is true about finalize() method?
Which of the following options will protect the underlying collections...
Which of the following options give the names of data structures that...
Consider the following code:...
Which of the following classes is new to JDK 1.6?
Consider the following code snippet:...
Consider the following code:...
You need to create a class that implements the Runnable interface to...
The return value of execute() method in Statement interface is...
Consider the following code:...
Which of the following are the valid ways of conversion from Wrapper...
Consider the following scenario:...
At which of the following given situations, unit tests are required to...
Consider the following code:...
Which of the following statements are correct regarding Static...
Consider the following code snippet:...
Consider the following program:...
Consider the following code:...
Consider the following code:...
Which of the following actions include the external library required...
Consider the following code snippet:...
Consider the following program:...
Consider the following code snippet:...
Consider the following code:...
X
OK
X
OK
Cancel
X
OK
Cancel
Back to top
Back to top
Advertisement