Sun Certified Java Programmer Scjp Exam
Comments
Description
Cover PageCertification Java Certified Programmer SCJP/OCJP Mock Author: JavaChamp Team Senior Java Developer @QuizOver.com Copyright (c) 2010-2014 About Us Powered by QuizOver.com The Leading Online Quiz & Exam Creator Create, Share, and Discover Quizzes & Exams http://www.quizover.com (2) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved Disclaimer All services and content of QuizOver.com are provided under QuizOver.com terms of use on an "as is" basis, without warranty of any kind, either expressed or implied, including, without limitation, warranties that the provided services and content are free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the provided services and content is with you. In no event shall QuizOver.com be liable for any damages whatsoever arising out of or in connection with the use or performance of the services. Should any provided services and content prove defective in any respect, you (not the initial developer, author or any other contributor) assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty constitutes an essential part of these "terms of use". No use of any services and content of QuizOver.com is authorized hereunder except under this disclaimer. The detailed and up to date "terms of use" of QuizOver.com can be found under: http://www.QuizOver.com/public/termsOfUse.xhtml (3) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved eBook Content License Creative Commons License Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0) http://creativecommons.org/licenses/by-nc-nd/3.0/ You are free to: Share: copy and redistribute the material in any medium or format The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following terms: Attribution: You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. NonCommercial: You may not use the material for commercial purposes. NoDerivatives: If you remix, transform, or build upon the material, you may not distribute the modified material. No additional restrictions: You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. (4) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved Table of Contents Quiz Permalink: http://www.quizover.com/pdf/oracle-certified-professional-java-programmer-scjp-ocjp-quiz-by-javach Author Profile: http://www.quizover.com/user/profile/Java.Champ 1. Java Certified Programmer - Strings - Constructors - Inner class - Flow Control - Declarations and Access Control - Interfaces and Abstract Classes - Exceptions - Inheritance - Arrays - Operators - Variables and Methods - Wrappers and Autoboxing - Garbage Collection - Overriding and Overloading - Collections - Generics - Formatting - I/O - Threads - Enums - Data Types - Static and init blocks - Serialization (5) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4. Chapter: Strings 1. Strings Questions (6) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.1. What is the expected output? Author: Yasser Ibrahim What is the expected output? public static void main(String[] args) { boolean stmt1 = "champ" == "champ"; boolean stmt2 = new String("champ") == "champ"; boolean stmt3 = new String("champ") == new String("champ"); System.out.println(stmt1 && stmt2 || stmt3); } Please choose only one answer: • true • false Check the answer of this question online on QuizOver.com: Question: Java objects comparison Permalink: http://www.quizover.com/pdf/java-objects-comparison (7) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . boolean stmt3 = "champ".http://www. System.println(stmt1 && stmt2 && stmt3).equals(new String("champ")).com/pdf/how-to-compare-java-objects (8) Powered by QuizOver.com QuizOver.quizover.2.com: Question: How to compare java objects? Permalink: http://www.4. What is the expected output? Author: JavaChamp Team What is the expected output? public static void main(String[] args) { boolean stmt1 = "champ" == "champ".toString()=="champ".1.com .out. boolean stmt2 = new String("champ").quizover. } Please choose only one answer: • true • false Check the answer of this question online on QuizOver. com .quizover.4.com: Question: What are common methods between String and StringBuffer? Permalink: http://www.1.http://www. Select the common methods.3.. which are defined for both type String and type StringBuffer ? Please choose all the answers that apply: • toString() • length() • append(String) • trim() • equals(Object) Check the answer of this question online on QuizOver.com QuizOver. which are defined for both type String a. Author: JavaChamp Team Select the common methods.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/what-are-common-methods-between-string-and-stringbuffer (9) Powered by QuizOver..quizover. 4.com: Question: What is the difference between String and StringBuffer? Permalink: http://www.quizover. } } Please choose all the answers that apply: • stmt1 • stmt2 • stmt3 • stmt4 • stmt5 Check the answer of this question online on QuizOver.toString()) .com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . boolean stmt2 = sb.toString() == s .4.quizover.com .1. boolean stmt4 = sb.equals(sb) . boolean stmt5 = s. String s = new String("javachamp").equals(s) .http://www.equals(s) .toString().equals(sb. boolean stmt3 = sb.com/pdf/what-is-the-difference-between-string-and-stringbuffer (10) Powered by QuizOver. boolean stmt1 = s. Which of the statements would evaluate to true? Author: JavaChamp Team Which of the statements would evaluate to true? public class Tester { public static void main(String[] args) { StringBuffer sb = new StringBuffer("javachamp"). com .4.equals(sb2) . Which of the statements will evaluate to true? Author: JavaChamp Team Which of the statements will evaluate to true? public class Tester { public static void main(String[] args) { StringBuffer sb1 = new StringBuffer("javachamp"). boolean stmt1 =sb1. boolean stmt4 = s1 == s2. StringBuffer sb2 = new StringBuffer("javachamp"). } } Please choose only one answer: • stmt1 • stmt2 • stmt3 • stmt4 Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . String s1 = new String("javachamp").com QuizOver.http://www.com/pdf/comparing-string-and-stringbuffer-in-java (11) Powered by QuizOver.equals(s2).quizover.com: Question: Comparing String and StringBuffer in java Permalink: http://www. String s2 = new String("javachamp"). boolean stmt2 = sb1 == sb2.5. boolean stmt3 = s1.1.quizover. 4.out.1. System.com QuizOver.out. System.print(null+stmt).quizover.com: Question: Concatenating String and null Permalink: http://www. } Please choose only one answer: • RuntimeException is thrown because of the first print statement • RuntimeException is thrown because of the second print statement • nullnullnullnull • nullnull • compilation error Check the answer of this question online on QuizOver.print(stmt+null). What is the expected output? Author: Yasser Ibrahim What is the expected output? public static void main(String args []) { String stmt = null.com .com/pdf/concatenating-string-and-null (12) Powered by QuizOver.http://www.6.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . quizover.http://www.1.println("true").7.equals(buffer2)) System. else System. StringBuffer buffer2 = new StringBuffer(buffer1).com: Question: Comparing StringBuffer using equals in java Permalink: http://www. } Please choose only one answer: • true • false Check the answer of this question online on QuizOver. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public static void main(String[] args) { StringBuffer buffer1 = new StringBuffer("javachamp").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/comparing-stringbuffer-using-equals-in-java (13) Powered by QuizOver.com .println("false").out.com QuizOver.out. if (buffer1.quizover.4. String s2 = null. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { String s1 = null. if (s1 == s2) System.http://www.com: Question: comparing null to String Permalink: http://www.print("B").8.print("A").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.com .1.quizover.quizover.out. } Please choose only one answer: • "AB" will be printed • "A" will be printed followed be a NullPointerException thrown • "B" will be printed • No output is produced Check the answer of this question online on QuizOver.equals(s2)) System.4. if (s1.com/pdf/comparing-null-to-string (14) Powered by QuizOver.out. com/pdf/methods-of-java-regex-pattern (15) Powered by QuizOver.com QuizOver. Which of the following methods can be invoked by an object of Patte.quizover.com .http://www.4.quizover.com: Question: Methods of java regex Pattern? Permalink: http://www..9..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1. Author: Yasser Ibrahim Which of the following methods can be invoked by an object of Pattern class? Please choose all the answers that apply: • compile • matches • group • toString Check the answer of this question online on QuizOver. String b = "javachamp".out.com/pdf/comparing-strings-for-equality-in-java (16) Powered by QuizOver.out. } } Please choose only one answer: • Compilation error • falsefalsetruetrue • truetruetruetrue • truefalsetruetrue Check the answer of this question online on QuizOver.10.1.quizover.print(b. System.http://www. String c = new String("javachamp"). What is the result of compiling and running the following program? Author: Yasser Ibrahim What is the result of compiling and running the following program? public class Tester { public static void main(String[] args) { String a = "javachamp".out.print(a==c). System.print(a==b).equals(c)).print(b. System.com QuizOver.quizover. System.equals(a)).com .com: Question: Comparing Strings for equality in java Permalink: http://www.out.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . com .quizover.split("//s")) { System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.com QuizOver. for (String token : stmt. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { String stmt = "JavaChamp is here to help you".com: Question: how to split String in java? Permalink: http://www.1.quizover.http://www.com/pdf/how-to-split-string-in-java (17) Powered by QuizOver.11.print(token + " ").4. } } } Please choose only one answer: • JavaChamp is here to help you • JavaChamp i here to help you • No output is produced • Compilation error Check the answer of this question online on QuizOver. util.com QuizOver.Matcher.12. Given the following code.regex.com: Question: How to parse String in java? Permalink: http://www.print(m. public class Tester { public static void main(String[] args) { Pattern p = Pattern.regex.start()+" "+m.com/pdf/how-to-parse-string-in-java (18) Powered by QuizOver.find()) { System.1.matcher("ab34ef0"). import java.quizover.out.util.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . what is the expected output? Author: JavaChamp Team Given the following code.quizover.com . } } } Please choose only one answer: • 0 ab345 f0 • 0 ab344 ef0 • 1 b35 f0 • 1 b345 f0 Check the answer of this question online on QuizOver.Pattern.group()). Matcher m = p.compile("[a-f]\\d+").http://www. what is the expected output? import java. while(m.4. 4.1.13. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { String s = ""; Integer x = 5; StringBuffer sb = new StringBuffer(); if (x < 15) s.concat("javachamp"); else sb.append("javachamp"); System.out.print(s + sb); } } Please choose only one answer: • javachamp • javachamp javachamp • No output is produced • Compilation error Check the answer of this question online on QuizOver.com: Question: How to use StringBuffer in java? Permalink: http://www.quizover.com/pdf/how-to-use-stringbuffer-in-java (19) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.14. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { String s = ""; Integer x = 5; StringBuffer sb = ""; if (x < 0) s.concat("javachamp"); else sb.append("javachamp"); System.out.print(s + sb); } } Please choose only one answer: • javachamp • javachamp javachamp • No output is produced • Compilation error Check the answer of this question online on QuizOver.com: Question: How to use java StringBuffer? Permalink: http://www.quizover.com/pdf/how-to-use-java-stringbuffer (20) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.15. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? import java.util.Scanner; public class Tester { public static void main(String[] args) { Scanner sc = new Scanner("javachamp 2009, true 239"); while (sc.hasNext()) { if (sc.hasNextBoolean()) System.out.print("Boolean"); if (sc.hasNextInt()) System.out.print("Int"); sc.next(); } } } Please choose only one answer: • IntBooleanInt • BooleanInt • IntInt • Compilation error Check the answer of this question online on QuizOver.com: Question: How to use java.util.Scanner? Permalink: http://www.quizover.com/pdf/how-to-use-javautilscanner (21) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.16. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { String str = "java"; StringBuffer sb = new StringBuffer("javachamp"); sb.insert(9, ".com"); str.concat("champ"); if (sb.length() < 6 || str.equals("javachamp")) { System.out.print(sb); } sb.delete(2, 7); System.out.print(sb); } } Please choose only one answer: • javachamp.comjamp.com • jamp • jamp.com • javachampjamp • jap Check the answer of this question online on QuizOver.com: Question: What are java StringBuffer methods? Permalink: http://www.quizover.com/pdf/what-are-java-stringbuffer-methods (22) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.17. What is the correct answer? Author: MrDick What is the correct answer? public class Test { public void method(StringBuffer sb) { System.out.println("StringBuffer method"); } public void method(String s) { System.out.println("String method"); } public static void main(String[] args) { Test test = new Test(); test.method(null); } } Please choose only one answer: • Stringbuffer method • String method • null • compilation error • Runtime Exception Check the answer of this question online on QuizOver.com: Question: java string and stringbuffer Permalink: http://www.quizover.com/pdf/java-string-and-stringbuffer (23) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.18. What is the correct output? Author: MrDick What is the correct output? class Test { public static void main(String[] args) { String jc = "javachamp_champ2012champ"; Pattern p = Pattern.compile(".{4}c+(m)*"); //line 1 Matcher m = p.matcher(jc); while(m.find()) { System.out.print(m.start()); } } } Please choose only one answer: • javacamp_c2012c • javachamp_champ2012champ • compliation error in line1 • 0615 • Runtime exception due line 1 Check the answer of this question online on QuizOver.com: Question: java regex and pattern Permalink: http://www.quizover.com/pdf/java-regex-and-pattern (24) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.19. What will be the Output? Author: Sudhakar Nagarajan What will be the Output? public class InnerClassThis { int x=10; public void foo() { System.out.println("Outer class"); } public class ReallyInner { public void foo() { System.out.println("Inner class"); } public void test() { this.foo(); InnerClassThis.this.foo(); } } public static void main(String... args) { InnerClassThis.ReallyInner i = new InnerClassThis().new ReallyInner(); i.test(); } } Please choose only one answer: • The code does not compile. • Inner class Outer class • The code compiles but throws runtime exception • Outer class Inner class Check the answer of this question online on QuizOver.com: Question: Sudhakar Nagarajan What will be the Output? public class InnerClassThis { int x=10; public void Permalink: http://www.quizover.com/pdf/sudhakar-nagarajan-what-will-be-the-output-public-class-innerclassthisint-x-10-public-void (25) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved java THAT CONTAINS: **/ abstract interface Veloz Permalink: http://www. Choose the correct(s) : Author: Diogo Dantas Choose the correct(s) : abstract interface Veloz { void metodo(String x). //4 } } } } Please choose all the answers that apply: • Can not be used private abstract at // 0 • • • • Can not be used abstract static at // 1 OK.1. } public void metodo(){ class Opa implements Veloz{ public void metodo(long x) throws IOException {} // 2 } } } public void test(){ class Opa2 implements Veloz{ public Integer metodo(int x) throws RuntimeException { // 3 return (Integer)(int) .4.5f. } public class A { private abstract interface Veloz{ Number metodo(int x).quizover.com: Question: Diogo Dantas /** AFTER COMPILING THIS FILE test. } // 0 abstract static class B{ // 1 private abstract static interface Veloz{ void metodo(long x) throws Exception.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.com QuizOver. Compiles Fine ! The IOException can be changed to InterruptedException Error at // 3 Error at // 4 Check the answer of this question online on QuizOver.com/pdf/diogo-dantas-after-compiling-this-file-test-java-that-contains-abstractinterface-veloz (26) Powered by QuizOver.20.com . http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .(27) Powered by QuizOver.com . print Permalink: http://www. What will be the output upon running this piece of code? Author: Divya Nagaraj What will be the output upon running this piece of code? public class Test { public static void hello(Collection x) { System.quizover.quizover. List x = null.com/pdf/divya-nagaraj-public-class-test-public-static-void-hello-collection-xsystem-out-print2064456 (28) Powered by QuizOver.21.out.1.println("List").com: Question: divya nagaraj public class Test { public static void hello(Collection x){ System. } } Please choose only one answer: • Collection • List • compilation error Check the answer of this question online on QuizOver.out.com .hello(x).http://www.println("Collection").com QuizOver. } } class Testing extends Test { public static void hello(List x) { System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. } public static void main(String[] args) { Test t = new Testing(). t.out. quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.http://www.4. Constructors Questions (29) Powered by QuizOver.com . Chapter: Constructors 1. com: Question: Can java constructors be declared static? Permalink: http://www.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Can a constructor be declared static? Author: Yasser Ibrahim Can a constructor be declared static? Please choose only one answer: • Yes • No Check the answer of this question online on QuizOver.com/pdf/can-java-constructors-be-declared-static (30) Powered by QuizOver.quizover.4.1.1.com QuizOver.http://www.quizover. http://www.com QuizOver..quizover. What are the legal modifiers which the constructor can be declared . Author: JavaChamp Team What are the legal modifiers which the constructor can be declared with? Please choose all the answers that apply: • public • protected • private • final • static • abstract Check the answer of this question online on QuizOver.2.4..quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: What are java constructors legal modifiers? Permalink: http://www.1.com/pdf/what-are-java-constructors-legal-modifiers (31) Powered by QuizOver.com . http://www.println(w).com: Question: Can java constructors be declared final? Permalink: http://www.com/pdf/can-java-constructors-be-declared-final (32) Powered by QuizOver.out. } public final Profile() { // line 5 System. What is the expected output? Author: JavaChamp Team What is the expected output? public class Profile { private Profile(int w) { // line 1 System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1.out.quizover.3.println(10).4.quizover. } public static void main(String args[]) { Profile obj = new Profile(50).com . } } Please choose only one answer: • Won't compile because of line (1) – constructor can't be private • Won't compile because of line (5) – constructor can't be final • 50 • 10 50 Check the answer of this question online on QuizOver.com QuizOver. com: Question: Can java constructors be marked static? Permalink: http://www.println(10).com QuizOver. } public static void main(String args[]) { Profile obj = new Profile(50).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1.com/pdf/can-java-constructors-be-marked-static (33) Powered by QuizOver. } public static Profile() { // line 5 System.out.quizover. What is the expected output? Author: JavaChamp Team What is the expected output? public class Profile { private Profile(int w) { // line 1 System.quizover.4.com .out.println(w). } } Please choose only one answer: • Won't compile because of line (1) – constructor can't be private • 10 50 • 50 • Won't compile because of line (5) – constructor can't be static Check the answer of this question online on QuizOver.4.http://www. com .5. } } class Tree extends Plant { Tree() { System. } } public class Test { public static void main(String args[]) { Tree tree = new Tree().out.1.http://www.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. } } Please choose only one answer: • Plant created Tree created • Tree created Plant created • RuntimeException • Compilation error Check the answer of this question online on QuizOver.println("Plant created").com: Question: When can call super() in java constructors? Permalink: http://www.quizover.out. super().println("Tree created"). What is the expected output? Author: Yasser Ibrahim What is the expected output? class Plant { Plant() { System.com/pdf/when-can-call-super-in-java-constructors (34) Powered by QuizOver.quizover. 6.com: Question: How to call super() in java constructor? Permalink: http://www.out.quizover.http://www.io.com QuizOver. throw new IOException().out.print("IOException is thrown in Tester").quizover.out. } catch (IOException e) { System. } catch (IOException e) { System. } } class AirJet extends AirPlane { public AirJet() throws IOException { try { super().com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/how-to-call-super-in-java-constructor (35) Powered by QuizOver. class AirPlane { public AirPlane() throws IOException { System.print("AirPlane").1.IOException. } } } public class Tester { public static void main(String args[]) { try { new AirJet(). What is the expected output? Author: JavaChamp Team What is the expected output? import java.4. } } } Please choose only one answer: • "AirPlaneIOException is thrown in AirJet" will be printed • "AirPlaneIOException is thrown in AirJetIOException is thrown in Tester" will be printed • "AirPlaneIOException is thrown in Tester" will be printed • Compile error Check the answer of this question online on QuizOver.print("IOException is thrown in AirJet"). where could it be? public class Tester { Tester() { } // line 1 static void Tester() { this().com QuizOver. compiler can"t determine wether a constructor Tester or method Tester is called Check the answer of this question online on QuizOver.com/pdf/how-to-call-this-in-java-constructor (36) Powered by QuizOver.com . The following code contains one compilation error. } // line 2 public static void main(String[] args) { // line 3 Tester().quizover.7. // line 4 } } Please choose only one answer: • At line 1. ambiguity problem. where could it be? Author: Yasser Ibrahim The following code contains one compilation error. constructor Tester must be marked public like its class • At line 2.com: Question: How to call this() in java constructor? Permalink: http://www.http://www. constructor call "this()" can only be called inside constructors • At line 3.1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. compilation error.quizover. quizover. Chapter: Inner class 1.http://www.com .com QuizOver. Inner class Questions (37) Powered by QuizOver.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.printVariables().print(Airplane.print(code).code).1. // line 6 box. // line 20 } } } Please choose only one answer: • Compile error because of lines 5-6 (incorrect instantiation) • Compile error because of line 20 (can't access Airplane's variables) • 2222 • 1111 • 2211 Check the answer of this question online on QuizOver.quizover.http://www. public void printVariables() { System.com QuizOver.1.com/pdf/how-to-access-an-outer-class-member-from-inside-its-inner-class (38) Powered by QuizOver.BlackBox box = airplane. What is the expected output? Author: JavaChamp Team What is the expected output? public class OuterTest { public static void main(String args[]) { Airplane airplane = new Airplane(). } } class Airplane { String code = "11".com .com: Question: How to access an outer class member from inside its inner class? Permalink: http://www.this. class BlackBox { String code = "22".new BlackBox(). //line 5 Airplane.4.quizover. // line 19 System.out. } } class Airplane { String code = "11".1.out.print(Airplane.4.com QuizOver.print(code).new BlackBox().http://www. // line 1 box.com: Question: How to access a member of an outer class from inside its inner class? Permalink: http://www. System.printVariables().out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the expected output? Author: JavaChamp Team What is the expected output? public class OuterTest { public static void main(String args[]) { Airplane.com/pdf/how-to-access-a-member-of-an-outer-class-from-inside-its-inner-class (39) Powered by QuizOver.quizover.com .2. // line 20 } } } Please choose only one answer: • Compile error because of line 1 (incorrect instantiation) • Compile error because of line 20 (can't access Airplane's variables) • 2222 • 1111 • 2211 Check the answer of this question online on QuizOver. class BlackBox { String code = "22".code).BlackBox box = new Airplane(). public void printVariables() { System.this.quizover. 1.4.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Which of the instantiations for a BlackBox are correct and compile-. // instantiation 2 Airplane. Airplane. // instantiation 3 Airplane airplane3 = new Airplane()..com QuizOver.quizover.http://www.new BlackBox().BlackBox box1 = airplane.quizover.new BlackBox().3.new BlackBox().. BlackBox box3 = airplane3. } } class Airplane { class BlackBox { } } Please choose all the answers that apply: • Instantiation 1 • Instantiation 2 • Instantiation 3 Check the answer of this question online on QuizOver.com: Question: How to instantiate an inner class inside main()? Permalink: http://www.com/pdf/how-to-instantiate-an-inner-class-inside-main (40) Powered by QuizOver. Author: JavaChamp Team Which of the instantiations for a BlackBox are correct and compile-free? public class OuterTest { public static void main(String args[]) { // instantiation 1 Airplane airplane = new Airplane().BlackBox box2 = new Airplane(). new Engine().quizover.com: Question: How to instantiate an inner class? Permalink: http://www.new Engine().com .quizover.http://www.4. // instantiation 2 AirJet.new Engine(). } class Engine{ } } Please choose all the answers that apply: • Instantiation 1 • Instantiation 2 • Instantiation 3 • Instantiation 4 Check the answer of this question online on QuizOver.com/pdf/how-to-instantiate-an-inner-class (41) Powered by QuizOver.com QuizOver.4. Which of the instantiations for a Engine are correct and compile-free? Author: JavaChamp Team Which of the instantiations for a Engine are correct and compile-free? public class AirJet { public static void main(String[] args) { // instantiation 1 Engine engine1 = new AirJet(). // instantiation 3 AirJet airjet = new AirJet().1. Engine engine3 = airjet.Engine engine2 = new AirJet(). // instantiation 4 Engine engine4 = new Engine().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . 1.4.com: Question: How to declare java inner class inside a method? Permalink: http://www. Are the lines 1 and 2 correct and free of compilation errors? Author: Yasser Ibrahim Are the lines 1 and 2 correct and free of compilation errors? public class AirPlane { public void fly(int speed) { final int e = 1. inner class can't access outer class local variables • Compilation error at line 2.com/pdf/how-to-declare-java-inner-class-inside-a-method (42) Powered by QuizOver.out. class FlyingEquation { { System.println(e).http://www.println(speed). inner class can't access method's arguments Check the answer of this question online on QuizOver.com .quizover.quizover.com QuizOver.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .5.// line 2 } } } } Please choose only one answer: • Both statements at lines 1 and 2 are correct • Both statements at lines 1 and 2 are incorrect and cause compilation errors • Compilation error at line 1 .// line 1 System. println(new Body(). What statement. String getPName() { // insert statement here } } } Please choose only one answer: • return Body.4.quizover..name.1. would produce output "Body" ? public class Body { String name = "Body".com .http://www.getPName()). } class Heart { String name = "Heart". .this.name.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .name.name.new Heart(). Author: JavaChamp Team What statement.com: Question: How java inner class access outer class? Permalink: http://www.quizover. Check the answer of this question online on QuizOver.com/pdf/how-java-inner-class-access-outer-class (43) Powered by QuizOver.com QuizOver.inserted independently at // insert statement here. • return this.super.inserted independently at // insert statement here.6.. • return super. public static void main(String[] args) { System.out. • return Body. whether program will compile? Author: Aroraila975 whether program will compile? public class outer { public static void main(String[] a) { static class inner{ } } } Please choose only one answer: • No.com: Question: java inner class Permalink: http://www.1. • Yes its correct Check the answer of this question online on QuizOver.http://www.4.quizover.com .com/pdf/java-inner-class (44) Powered by QuizOver.com QuizOver.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . because local class can not be explicitly declared static.7. quizover. Outer.new Inner().6 • 7.http://www.quizover. // line 5 } } public static void main(String[] args) { int i = 6.com/pdf/java-inner-class-acces-control (45) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.1. // line 3 System.i = i. // line 1 Outer(int i ){ // line 2 this. What is the right output? Author: MrDick What is the right output? class Outer { private int i = 5.print(".out.4.6 • 5.com .7 • Complilation error in line 6 • Compilation error in line 5 inner class can't acces to private variables Check the answer of this question online on QuizOver.print(++i).Inner in = new Outer(i).6 • 7.com: Question: java inner class acces control Permalink: http://www.8. // line 6 } } Please choose only one answer: • 6. // line 4 } class Inner{ Inner(){ System.out."+ i++). com: Question: java inner class access Permalink: http://www.com QuizOver.innerMethod().quizover.http://www.com/pdf/java-inner-class-access (46) Powered by QuizOver. // line 5 public OuterClass() { InnerClass inner = new InnerClass().println(x). } class InnerClass { public void innerMethod() { System. // line 7 inner.4. What will be the result of above code ? Author: Kausik What will be the result of above code ? public class Test { public static void main(String[] args) { new OuterClass().// line 3 } } class OuterClass { private int x = 9.9.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. } } } Please choose only one answer: • (1) Prints 9 • (2) Error during compilation at line 3 • (3) Error during compilation at line 5 • (4) Error during compilation at line 7 Check the answer of this question online on QuizOver.1.quizover. 4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.com QuizOver.com . Flow Control Questions (47) Powered by QuizOver. Chapter: Flow Control 1.http://www. j++) { if (a < 5) { break. } System.print(i + j). } } Please choose only one answer: • 2 • No output is produced • Compile Error • Runtime exception is thrown • 24 Check the answer of this question online on QuizOver.com: Question: How to write java labeled for loop? Permalink: http://www.1.goLoop(15).quizover.out.quizover.4. i++) { for (int j = 1.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . j < 2.com QuizOver.com/pdf/how-to-write-java-labeled-for-loop (48) Powered by QuizOver. i < 2. } if (a > 5) { break start.1.com . What is the expected output? Author: JavaChamp Team What is the expected output? public class LoopTest { public static void goLoop(int a) { start: for (int i = 1. } } } public static void main(String args[]) { LoopTest. quizover.2.4.com/pdf/how-to-use-break-and-continue-in-java-for-loop (49) Powered by QuizOver.out. i < 2.com: Question: How to use break and continue in java for loop? Permalink: http://www.1.goLoop(15).quizover.print(i + j).com QuizOver. } System.http://www. j++) { if (a > 5) { break start. } } Please choose only one answer: • 2 • No output is produced • Compile Error • Runtime exception is thrown • 24 Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com . } } } public static void main(String args[]) { LoopTest. What is the expected output? Author: JavaChamp Team What is the expected output? public class LoopTest { public static void goLoop(int a) { start: for (int i = 1. i++) { for (int j = 1. j < 2. goLoop(15).com: Question: How to use break and continue loop control commands in java? Permalink: http://www. i++) { for (int j = 1. j++) { if (a > 5) { break start.print(i + j).com/pdf/how-to-use-break-and-continue-loop-control-commands-in-java (50) Powered by QuizOver.out. i < 2. } System.4.com .quizover.com QuizOver.1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class LoopTest { public static void goLoop(int a) { start.3.quizover. } } Please choose only one answer: • 2 • No output is produced • Compile Error • Runtime exception is thrown • 24 Check the answer of this question online on QuizOver.http://www. } } } public static void main(String args[]) { LoopTest. for (int i = 1. j < 2. com/pdf/how-to-use-break-and-continue-in-java-labeled-for-loop (51) Powered by QuizOver. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class LoopTest { public static void goLoop(int a) { outside: for (int i = 0.quizover.goLoop(15).print(j). if (a > 5) { continue outside. i < 3.1. } } } } public static void main(String args[]) { LoopTest.4.4. } } Please choose only one answer: • 121212 • No output is produced • Compile Error • Runtime exception is thrown • 111 Check the answer of this question online on QuizOver. j < 3.http://www.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . j++) { System.quizover. i++) { inside: for (int j = 1.com QuizOver.com: Question: How to use break and continue in java labeled for loop? Permalink: http://www.com . //line 8 break outside.com . i++) {// line 4 inside: System. // line 9 } } } } Please choose only one answer: • Compile Error at line 5 • Runtime exception is thrown at line 5 • Compile Error at line 8 • Runtime exception is thrown at line 8 • No output is produced • Compile Error at line 4 • Compile Error at line 9 • Runtime exception is thrown at line 9 Check the answer of this question online on QuizOver. i < 3. // line 5 for (int j = 1.5.4. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class LoopTest { public static void main(String args[]) { int a = 15.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .print(i).1. j < 3. j++) { if (a > 5) continue inside.quizover.com QuizOver.com: Question: How to use break and continue in java loop? Permalink: http://www.http://www. outside: for (int i = 0.quizover.com/pdf/how-to-use-break-and-continue-in-java-loop (52) Powered by QuizOver. 1.http://www. j++) { System. if (a++ > 6) continue inside. i < 3.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.print(j). i++) { inside: for (int j = 1.quizover. } } } } Please choose only one answer: • Compile error • Runtime exception is thrown • 1 • 123 Check the answer of this question online on QuizOver.6.com: Question: How to use continue and break in java loop? Permalink: http://www.out.4. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class LoopTest { public static void main(String args[]) { int a = 5. break outside.com/pdf/how-to-use-continue-and-break-in-java-loop (53) Powered by QuizOver. outside: for (int i = 1.com . j < 3.quizover. print(j). must have break statement within each case • 17 • 13 Check the answer of this question online on QuizOver. } System.out. can"t use constant 1 in the switch.com/pdf/how-to-write-java-switch-statement (54) Powered by QuizOver. default must be the last statement after all the cases • Compile error.1. case 40: j += 2. default: j += 3.http://www. case 0: j += 4.quizover. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { int j = 10.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } Please choose only one answer: • Compile error.7.com: Question: How to write java switch statement? Permalink: http://www.com QuizOver.quizover.4.com . must be final variable • Compile error. switch (1) { case 20: j += 1. 4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } while (false).quizover.print("outside").quizover.http://www. while (false) { System.8.out.out.com: Question: do while loop syntax in java Permalink: http://www.com QuizOver.print("inside do"). } System. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { do { System.com .print("inside while").com/pdf/do-while-loop-syntax-in-java (55) Powered by QuizOver.1.out. } } Please choose only one answer: • inside dooutside • outside • compilation error because of the second loop (while statement) Check the answer of this question online on QuizOver. quizover. i++) { switch (i) { case 5: { System.1.http://www.out. } default: { System.com: Question: Java switch statement syntax Permalink: http://www.com QuizOver. Which of the following is correct after running this code ? Author: Yasser Ibrahim Which of the following is correct after running this code ? public class Tester { public static void main(String[] args) { char code = 'a'.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. for (int i = 1.com/pdf/java-switch-statement-syntax (56) Powered by QuizOver.4.println("default").9. } } } } } Please choose all the answers that apply: • match will be printed 0 time • match will be printed one time • default will be printed 10 times • default will be printed 11 times Check the answer of this question online on QuizOver. i <= 10.println("match").com .quizover. 4. } } Please choose only one answer: • one--two-• onetwo • onetwo-• Tester--one--two-• Testeronetwo-- Check the answer of this question online on QuizOver..10.print(str).print("--").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: How to use java main method argument? Permalink: http://www. Author: JavaChamp Team What is the result of running the following program (which was compiled fine) given the command line: java Tester one two public class Tester { public static void main(String[] args) { if (args.com/pdf/how-to-use-java-main-method-argument (57) Powered by QuizOver.quizover.com QuizOver.com .out.out.http://www.length > 0) for (String str : args) System.. What is the result of running the following program (which was comp.1.quizover. System. http://www.. which of if-statements declared is correc. // stmt 1 if (x>0){} // stmt 2 if (x=9){} else {} // stmt 3 if (true){ } else if (x<0){ } // stmt 4 if (true){ } else (x<0){ } else { } // stmt 5 if(true){ if (false){ } else { } } else { if (true){ } } } } Please choose all the answers that apply: • stmt 1 • stmt 2 • stmt 3 • stmt 4 • stmt 5 Check the answer of this question online on QuizOver. Author: JavaChamp Team Given the following code.com .com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . which of if-statements declared is correctly written and causes no compilation error? public class Tester { public static void main(String[] args) { int x = 9.11.1..quizover. Given the following code.4.com: (58) Powered by QuizOver. quizover.com QuizOver.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .quizover.Question: how to write if statement in java? Permalink: http://www.com/pdf/how-to-write-if-statement-in-java (59) Powered by QuizOver. } Please choose only one answer: • 0 • 1 • 2 • 3 • Compilation error Check the answer of this question online on QuizOver.quizover. System.com: Question: How to write do while statement in java? Permalink: http://www.4.com .com QuizOver.com/pdf/how-to-write-do-while-statement-in-java (60) Powered by QuizOver. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { boolean flag = false.println(x).quizover.out. } while (flag=!flag).1. int x = 0.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .12. do { x++.http://www. com QuizOver. long x = 2.BLUE}. case BLUE: System.println("Blue"). public static void main(String []args){ Color clr = Color. } } } Please choose only one answer: • a) 2 Green • b) 2 3 Green • c) 2 3 • d) Compilation error at #1 • e) Compilation error at #2 • f) Runtime exception at #2 (61) Powered by QuizOver. default: System.out. What is the output of this code? Author: Abhishek Sawant What is the output of this code? public class SwitchTest{ enum Color {RED.println("1").println("2").println("Green").http://www.out.com .quizover.out.out.println("Red").4.GREEN.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . case GREEN: System.1. break.out. case 2: System. switch(x){// #1 case 1: System. case 3: System.println("3").13.out.out. } switch(clr){ // #2 case RED: System. break.println("default"). break. break. break. break.GREEN. quizover.com .com: Question: java switch control example Permalink: http://www.quizover.http://www.com/pdf/java-switch-control-example (62) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.Check the answer of this question online on QuizOver. out. switch(b) { case 1: System.com .quizover.com QuizOver. case 2: System. break. • prints 3 Check the answer of this question online on QuizOver.out. } } } Please choose only one answer: • compiler error • prints 2 • Runtime exception is generated.1.14.com: Question: how to write switch case statement in java Permalink: http://www.com/pdf/how-to-write-switch-case-statement-in-java (63) Powered by QuizOver.4. int b=2.println("2"). break. case a: System.quizover.out. break.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . what will be the output of compiling and running this code: Author: Pankaj Gupta what will be the output of compiling and running this code: class TestByte{ public static void main(String arg[]) { final Integer a=10.println("3").println("1").http://www. . Author: Pedro Kowalski Knowing that character 'a' has a numeric value equal to 97.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . what is the output of the following code public class CaseTest { public static void main(String..out..15.4. break. s) { char c = 'a'.com .println("a").1.out.http://www. what is. } } } } Please choose only one answer: • a • (int)a • a (int)a • compilation fails Check the answer of this question online on QuizOver.com/pdf/switch-with-char-variable-and-duplicate-cases-in-java (64) Powered by QuizOver.println("(int)a").quizover. break..com: Question: switch with char variable and duplicate cases in java Permalink: http://www. switch (c) { case 'a': { System.com QuizOver.quizover. Knowing that character 'a' has a numeric value equal to 97. } case 97: { System. 16.1.println("Init Block").4...out.http://www.} {System.} ExamDemo3(){ System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .println("Constructor Runs"). } static{System. } } Please choose only one answer: • Compile Time Error • ExceptionIntializerError is thrown • Init Block Constructor Runs static init 2 Inside main method Check the answer of this question online on QuizOver.com .quizover.com: Question: static block order changed Nikhil Kumar Permalink: http://www.out.com QuizOver.} public static void main(String. what is the result of running and the compiling the following code? Author: Nikhil Kumar what is the result of running and the compiling the following code? class ExamDemo3{ static{new ExamDemo3().println("static init 2"). args){ System.quizover.com/pdf/static-block-order-changed-nikhil-kumar (65) Powered by QuizOver.out.println("Inside main method").out. 4. Chapter: Declarations and Access Control 1. Declarations and Access Control Questions (66) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.1. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static int x = 4; public Tester() { System.out.print(this.x); // line 4 Tester(); } public static void Tester() { // line 8 System.out.print(this.x); // line 9 } public static void main(String... args) { // line 12 new Tester(); } } Please choose only one answer: • Compile error at line 4 (static x must be only accessed inside static methods ) • Compile error at line 8 (constructors can't be static ) • Compile error at line 9 (static methods can't invoke this ) • Compile error at line 12 (invalid argument type for method main ) • 44 Check the answer of this question online on QuizOver.com: Question: Can java static methods invoke this? Permalink: http://www.quizover.com/pdf/can-java-static-methods-invoke-this (67) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.2. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static int x = 4; int y = 9; public Tester() { System.out.print(this.x); // line 7 printVariables(); } public static void printVariables() { System.out.print(x); // line 12 System.out.print(y); // line 13 } public static void main(String... args) { // line 16 new Tester(); } } Please choose only one answer: • Compile error at line 7 (static x must be only accessed inside static methods ) • Compile error at line 13 (static methods cant make reference to non-static variables ) • Compile error at line 16 (invalid argument type for method main ) • 49 • Compile error at line 12 (must access x by writing Tester.x) Check the answer of this question online on QuizOver.com: Question: What can java static methods make references to? Permalink: http://www.quizover.com/pdf/what-can-java-static-methods-make-references-to (68) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.3. You have two packages, trunk1 and trunk2 where class Sheet declared... Author: Yasser Ibrahim You have two packages, trunk1 and trunk2 where class Sheet declared in trunk1 and class Container declared in trunk2, the following code contains a compilation error, where could it be? package trunk1; public class Sheet { public static int pageNumber = 99; // line 1 Sheet() {} // line 2 } package trunk2; import trunk1.Sheet; public class Container { public static void main(String... args) { //line 1 System.out.print(Sheet.pageNumber); //line 2 Sheet sheet = new Sheet(); //line 3 } } Please choose only one answer: • In package trunk1 at line 2, constructor Sheet must be marked public like its class • In package trunk2 at line 1, invalid string argument for method main() • In package trunk2 at line 2, invalid access to member pageNumber • In package trunk2 at line 3, invalid call to constructor Sheet() Check the answer of this question online on QuizOver.com: Question: How to access a class from another package in java? Permalink: http://www.quizover.com/pdf/how-to-access-a-class-from-another-package-in-java (69) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.4. You have three packages, trunk1,trunk2 and trunk3, What is the expe... Author: JavaChamp Team You have three packages, trunk1,trunk2 and trunk3, What is the expected output of compiling and running file Tester? package trunk1; public class Account { Account() { //line 1 System.out.println("Account"); } } package trunk2; import trunk1.Account; public class CurrentAccount extends Account{ public CurrentAccount() { // line 2 System.out.println("CurrentAccount"); } } package trunk3; import trunk1.Account; import trunk2.CurrentAccount; // line 3 public class Tester { public static void main(String[] args) { Account c = new Account(); // line 4 CurrentAccount ca = new CurrentAccount(); } } Please choose all the answers that apply: • Account CurrentAccount • Account Account CurrentAccount • Compilation error in package trunk1 at line 1 • Compilation error, in package trunk2 at line 2 (70) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved • • Compilation error, in package trunk3 at line 3 Compilation error, in package trunk3 at line 4 Check the answer of this question online on QuizOver.com: Question: packages and access scope in java Permalink: http://www.quizover.com/pdf/packages-and-access-scope-in-java (71) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.5. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static int p = test(); //line 1 static public int test() { System.out.print(p); //line 4 return 99; } public static void main(String[] args) { System.out.print(p);//line 11 } } Please choose only one answer: • 099 • Compilation error at line 1, p must be initialized by a value • Compilation error at line 4, using uninitialized variable p • Compilation error at line 11, p must be called using its class by writing Tester.p Check the answer of this question online on QuizOver.com: Question: How to use java static members? Permalink: http://www.quizover.com/pdf/how-to-use-java-static-members (72) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved at line 2 add : new A().A(). at line 2 add : new subPackage.1.quizover.*.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .A.4.6. • at line 1 add: import package.com/pdf/how-to-access-java-class-from-another-package (73) Powered by QuizOver.com . Consider the following two classes declared and defined in two diff.*. Check the answer of this question online on QuizOver. what can be added in class B to form what considered a correct access to class A from main() method of class B? package subPackage.A(). Author: JavaChamp Team Consider the following two classes declared and defined in two different packages.com QuizOver. at line 2 add : new A(). • at line 1 add nothing at line 2 add : new subPackage. • at line 1 add: import subPackage...http://www. • at line 1 add: import subPackage. public class A { } package anotherPackage.com: Question: How to access java class from another package? Permalink: http://www. // line 1 public class B { public static void main(String[] args) { // line 2 } } Please choose all the answers that apply: • at line 1 add nothing at line 2 add : new A(). 4.1.7. Given the following declarations, what is considered a correct stat... Author: JavaChamp Team Given the following declarations, what is considered a correct statement? interface Chewable {} interface Eatable extends Chewable{} class Vitamin{} class Food implements Eatable { Vitamin[] vitamins;} Please choose all the answers that apply: • Eatable is Chewable • Vitamin is Eatable • Food is Chewable • Food has Vitamin • Vitamin has Food • Food is an Object Check the answer of this question online on QuizOver.com: Question: types of relationships between java classes Permalink: http://www.quizover.com/pdf/types-of-relationships-between-java-classes (74) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.8. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? class Base { private Base() {System.out.print("Base");} } public class Derived extends Base { public Derived() {System.out.print("Derived");} public static void main(String[] args) { new Derived(); } } Please choose only one answer: • BaseDerived • Derived • Exception is thrown at runtime • Compilation error Check the answer of this question online on QuizOver.com: Question: Can java constructor be private? Permalink: http://www.quizover.com/pdf/can-java-constructor-be-private (75) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.9. Which of the following is true? Author: Yasser Ibrahim Which of the following is true? Please choose all the answers that apply: • When a class marked final, it cannot be extended • When a method marked final, it cannot be overridden • When a method marked final, it cannot be overloaded • Local variables of a method cannot be final • A variable of a primitive type (int,float,..) which marked final, its value at initialization cannot be changed Check the answer of this question online on QuizOver.com: Question: what does final do in java? Permalink: http://www.quizover.com/pdf/what-does-final-do-in-java (76) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.10. What does it mean to mark a calss strictfp? Author: JavaChamp Team What does it mean to mark a calss strictfp? Please choose only one answer: • it means this class can't be subclassed • it means this class can never be instantiated and it is to be extended • it means that any method code in the class will conform to the IEEE 754 standard rules for floating points Check the answer of this question online on QuizOver.com: Question: strictfp in java Permalink: http://www.quizover.com/pdf/strictfp-in-java (77) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.11. What can be marked with strictfp modifier? Author: Yasser Ibrahim What can be marked with strictfp modifier? Please choose all the answers that apply: • an interface • a class • a member method • a member field • a local variable Check the answer of this question online on QuizOver.com: Question: strictfp modifier in java Permalink: http://www.quizover.com/pdf/strictfp-modifier-in-java (78) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.12. A top level Java class can have the following modifiers: Author: JavaChamp Team A top level Java class can have the following modifiers: Please choose all the answers that apply: • strictfp and final • abstract and final • public and abstract • protected • private Check the answer of this question online on QuizOver.com: Question: top level class modifiers in java Permalink: http://www.quizover.com/pdf/top-level-class-modifiers-in-java (79) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.13. An inner class in java can have the following modifiers (at the sam... Author: JavaChamp Team An inner class in java can have the following modifiers (at the same time): Please choose all the answers that apply: • public and abstract • abstract and final • protected • private Check the answer of this question online on QuizOver.com: Question: inner class modifiers in java Permalink: http://www.quizover.com/pdf/inner-class-modifiers-in-java (80) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved } } Please choose only one answer: • Compilation error • IllegalArgumentException is thrown at runtime.quizover.4.println(i). } public static void main(String. } static int demo(){ System.} InitDemo(){ System.com QuizOver.out.println("Inside Demo").14.com: Question: static public private access modifiers java nikhil kumar Permalink: http://www.http://www.out. args){ System. • Inside Demo 10 Hello 2 • Hello 2 Inside Demo 10 Check the answer of this question online on QuizOver..out. What is the output ? Author: Nikhil Kumar What is the output ? class InitDemo{ static int i=demo().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .println("hello 1").println("Hello 2").1.quizover.com ..out. return 10. static{System.com/pdf/static-public-private-access-modifiers-java-nikhil-kumar (81) Powered by QuizOver. com QuizOver.1.4.quizover. there is compliation error(s) Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.com .com: Question: java final strictfp public class Permalink: http://www.com/pdf/java-final-strictfp-public-class (82) Powered by QuizOver. This is legal or not? Author: MrDick This is legal or not? final strictfp public class Parent implements Serializable {} Please choose only one answer: • legal and compile free • No.http://www.15. f. // line 16 Please choose all the answers that apply: • lines 1.http://www. Author: AlinaIoana Florea Which of the following are NOT LEGAL Java identifiers according to the "java language specification"? int .4. // line 11 int foo = 3.com QuizOver. // line 4 int this_is_a_way_too_long_name_for_an_identifier.com . // line 7 float . // line 6 int -e. // line 15 public abstract void addEvent(). c.contain invalid characters for Java identifiers • line 5 .. // line 14 int Volatile = 6.com/pdf/question-alinaioana-florea-legal-java-identifiers (83) Powered by QuizOver. // line 12 int Foo = 3.is too long line 16 . 3. 11 and 14 Check the answer of this question online on QuizOver." even if assigned to a numeric or floating point variable • line 7 . // line 9 int true = 10.can NOT contain "#" and ".com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover. // line 13 int continue = 6. :h.com: Question: AlinaIoana Florea legal java identifiers Permalink: http://www. // line 1 int ______9_y. nor can a Java identifier start with a digit • lines 10. // line 8 double _$_$. // line 3 int £b_. // line 5 int d3#.can NOT contain the characters "-" and ":". 7g.16. // line 10 int null = 4.in not a valid JavaBean identifier for a method that want to add a listener to an event source • lines 6 and 8 . Which of the following are NOT LEGAL Java identifiers according to . 4 .quizover.1.. // line 2 int €a. .com QuizOver.the names of the methods do not match the type of argument they receive + JavaBeans adder/remover methods should always end with "Listener" • line 2 .quizover.quizover.JavaBeans methods must be public in order to provide access to the private variables of a class + it's missing an argument of type XListener • line 4 . Author: AlinaIoana Florea Which of the following are NOT valid JavaBeans identifiers for methods that add/remove listeners from an event source? // Event subscribers: public void addXListener(MyListener m) // line 1 void addXListener() // line 2 public void addEvent(Event e) // line 3 public void addEventListener(EventListener e) // line 4 // Event removers: public void removeMyListener(MyListener m) // line 5 public void removeMyListener() // line 6 public void deleteActionListner(ActionListsner m) // line 7 Please choose all the answers that apply: • lines 1 and 3 .com: Question: illegal javabeans identifiers for methods that add /remove listeners Permalink: http://www.4.it misses the event to be removed • line 7 .com/pdf/illegal-javabeans-identifiers-for-methods-that-add-remove-listeners (84) Powered by QuizOver.com .17.it's adding or missing something • line 5 .should be "remove" instead of "delete" Check the answer of this question online on QuizOver.1..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www. Which of the following are NOT valid JavaBeans identifiers for meth.the name of its argument should be more meaningful • line 6 . are adding or missing some things • line 10 ..will produce a compile-time error due to invalid Java identifier • line 3 .4.com QuizOver.quizover. and "set" should be used instead of "put" and "modify" line 8 . Which of the following are NOT valid JavaBeans method identifiers f. so it should be "get" instead of "is" Check the answer of this question online on QuizOver. Author: AlinaIoana Florea Which of the following are NOT valid JavaBeans method identifiers for setters/getters of private class variables? // Property setters: void setCustomername() // line 1 public int modifyValue(int val) // line 2 public void setCustomerName(String customer) // line 3 public void setIsAlive(boolean isAlive) // line 4 public void addSize(int size) // line 5 public void putSize(int size) // line 6 // Property getters: public int getMyValue() // line 7 public int getAccount#(String clientName) // line 8 protected boolean getHappy() // line 9 public boolean isHappy() // line 10 public boolean getHappy() // line 11 public int isNrOfFlowers() // line 12 Please choose all the answers that apply: • lines 1 and 9 .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .according to JavaBeans "add" should be used only with listener methods.quizover.JavaBeans methods must be public in order to provide access to the private variables of a class • lines 2.1."nrOfFlowers" seems to be of type "int" not "boolean".http://www.18. as that's what the method is returning.com/pdf/legal-javabeans-method-identifiers-for-setters-getters (85) Powered by QuizOver. 5 and 6 . 7 and 11 .com ..it should be getHappy() because it's a getter method as it returns a value • line 12 .com: Question: legal javabeans method identifiers for setters /getters Permalink: http://www.the method's argument name should match the one its name: "customerName" • lines 4. com/pdf/java-comments-packages-imports (86) Powered by QuizOver.Runnable.OR make ALL classes in the file "default" • "import java.java: public /*x1*/ class /*x2*/ Animal implements Runnable {} package test2.quizover.19.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . /*x4*/public class Dog extends Animal implements /*x5*/ Serializable { void /*x6*/ doStuff(/*x7*/int arg1.rename "Animal" to "AnimalXyZ" as the only public class in a . int /*x8*/ arg2) {} // wrong comments } class X{} class Y{} Please choose all the answers that apply: • remove the "x#" comments.1.4. as only one class can be public in a .java file must match the name of the file ." is necessary at beginning of the file Check the answer of this question online on QuizOver.com QuizOver.java: Author: AlinaIoana Florea Correct the code in AnimalXyZ.io. they are placed in wrong places • move the package and the import statements at the beginning of the file • make "Animal" and "Dog" abstract as they do NOT implement the run() from the Runnable interface • remove the "public" from "Dog".com: Question: java comments packages imports Permalink: http://www.lang.http://www.quizover.java file • . Correct the code in AnimalXyZ. /*x3*/import java.com .Serializable. 1. static void add(int. 2). static void add(int[]. add(1). static void add(int args.20.. args.. Author: AlinaIoana Florea Choose all the lines which if inserted independently instead of "//insert code here" will allow the following code to compile: public class Test { public static void main(String[] args) { add().com ..args){} .quizover. void add(Integer.. args){} • 5.. args){} • 2.4. Check the answer of this question online on QuizOver. add(1.com QuizOver.quizover...com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . int y){} • 3.. } // insert code here } Please choose only one answer: • 1.http://www.. static void add(int.com: Question: correct usage of var-args Choose all the AlinaIoana Oracle Certified Permalink: http://www.com/pdf/question-correct-usage-of-var-args-choose-all-the-alinaioana-oracle-ce (87) Powered by QuizOver... Choose all the lines which if inserted independently instead of "//..){} • 4. out.out. Correct the following code: (consider the packages as each being in.com QuizOver.x2 + x1. // line 7 X1 x1 = new X1(). // line 6.println(x1. import pkgA.http://www.println(x1.*.1. private int x4 = 4.out. // line 2 int x3 = 33. Author: AlinaIoana Florea Correct the following code: (consider the packages as each being in a different file) package pkgA. int x3 = 3. // line 2 System. // line 4 X1 x1 = new X1().1 X2 x2 = new X2(). private int x4 = 44.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .x1+ x1. class Y extends X1 { Y() { System. // line 8 System.out.x4). // line 2 protected int x2=22. } class X2 extends X1 { private int x4 = 4. // line 6.com .4. // line 4 } } protected class X3 {} // line 5 private class X4 {} // line 5 //_____________________________________________________ package pkgB.out.x1 + x1..x3 + x1. // line 3. public class X1 { X1() // line 1 { public int x1 = 11.x4).2 } } public class Test extends Y { (88) Powered by QuizOver.println(x1 + "" + x2 + x3 + x4).x3 + x1.println(x1 + x2 + x3 + x4). System.quizover. // line 3 } public int x1 = 1. static protected int x2 = 2.println(x1 + x2 + x3 + x4).5 public X2() { System.21.x2 + x1.. x2 + y.go().public static void main(String[] args) { new Test(). And a similar thing is on line 7.1 Y y = new Y().quizover.2 } } Please choose all the answers that apply: • line 1 .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .out.local/method variables can be only "final" or "default" • line 3 .out. // line 6.1 Check the answer of this question online on QuizOver.5 .is not allowed to define a var with the same name as in the superclass • lines 4 . System.x4).com: Question: java access modiers for non inner classes Permalink: http://www.x1+ y. • lines 2 .X1's constructor must be public for "new" to succeed on line 8. private or protected • lines 6 . // line 6.x3 + y. which will work only if the class X2 is made public in its package.com/pdf/java-access-modiers-for-non-inner-classes (89) Powered by QuizOver.quizover. classes are allowed to be also static.println(x1 + x2).com QuizOver.should follow the same rules as the lines 4: "default" and "private" variables must be removed + the "protected" vars kept only when used through inheritance: on lines 6.can not print "x4" as it's private in class X1 so it can be used only inside X1 • lines 5 .won't compile because of the quotes added to those integers line 3.when defined in a package. } void go() { System.println(y.http://www. print(B).22.com .http://www. new Test(). final static void doStuff() { System.com/pdf/how-to-write-java-final-classes-methods-and-primitives (90) Powered by QuizOver.can not overload a final inherited method • line 2 .can not make a constructor final because it's not inheritable so it can not be anyway overridden • lines 3 .can not override a final inherited method • line 5 ."final" can not be mixed with "private" Check the answer of this question online on QuizOver. } } public class Test extends X2 { public static void main(String[] args) { doStuff(). (SCJP6) Correct the following code: Author: AlinaIoana Florea (SCJP6) Correct the following code: final class X1 { final X1() { System.quizover. } static void doStuff() {} // line 4 void doStuff(int arg) { System.can not extend/subclass a final class • Can not use in class X2 the same variable and method names as in its superclass X1 • line 4 .out.println("hello from Test").out. final private void doStuff() {} // line 2 } class X2 extends X1 // line 3 { final int B = 9.out.1.com: Question: how to write java final classes methods and primitives? Permalink: http://www.doStuff(3).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .println("hello from X2"). } // line 1 final int B = 9.4. } // line 5 } Please choose all the answers that apply: • line 1 .com QuizOver.quizover. println("In X" + a + b). doStuff(). but an error will occur because of the way "a" is commented leaving two "+" inside the print() • line 6 . } // line 4 } public class Test extends X { public static void main(String[] args) { X x = new X(). // line 5.out.23.com .com QuizOver. } // line 3 static void doStuff() { System."static" can not mark an initialization block {} • lines 2 .quizover. // line 5 X.2 } void doStuff() // line 6 { System.1.a static method can access non-static variables("a").println("In X" + /*a*/ + b).a non-static context can access only non-static variables • line 4 . void doX(){ System.quizover.com: Question: how to write java static non inner classes? Permalink: http://www. static int b.http://www. } // line 2 static X() {} // line 1 int a.doStuff(). } } Please choose all the answers that apply: • lines 1 . (SCJP 6) Find the errors in: Author: AlinaIoana Florea (SCJP 6) Find the errors in: static class X // line 1 { static { a = 3.com/pdf/how-to-write-java-static-non-inner-classes (91) Powered by QuizOver.println("In Test"). x.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved ."static" can not mark classes and constructors • line 2 .doStuff(). so it must keep its static status + "static" is needed also because it's called directly in the static method main() Check the answer of this question online on QuizOver.to be a valid override it must not be less accessible."b" must be used instead of "a" as in a static context(method/init block) it's possible to access only static variables • lines 3 .out.4. http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.com QuizOver.(92) Powered by QuizOver.com . // line 1 static { System. __x < 3.everything in Java must be within a class line 2. } // line 1 class X { int x.http://www.quizover.1.com/pdf/how-to-write-java-variable-declarations (93) Powered by QuizOver.println(x + y). x = 1. // line 6 System. // line 7 } } Please choose all the answers that apply: • lines 1 . int #lb = 7.will produce a run-time infinite loop which will crash JVM Check the answer of this question online on QuizOver.println(x + y + z).will not compile because of the added quotes • line 7 .out.com .4.com: Question: how to write java variable declarations? Permalink: http://www.println(new X()).out. // line 4 Boolean []b[].24. System. __x++) .out.an array must specify its size only when creating an object of its type not at declaration • line 6 . static int y.will produce a compilation error because it's using an invalid Java identifier • the "for" statement before line 3 will not compile because of the semicolon following it • line 4 .out.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .can not print here • line 3 . // line 3 long [] arr [5]. Spot the errors in: Author: AlinaIoana Florea Spot the errors in: static int x. // line 5 System.quizover.com QuizOver.println(x). static Integer z = new Integer(1). // line 2 X() { for(int __x = 0.println(x + y + "" + z). System. // line 1 B=7. // line 2 System.quizover. // line 4 x.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.1.out.println(x.out.out.25.print(x.com QuizOver.a = 3. } int a.http://www.print(B). B=8.print(B).print(B). System. x = new X().com: Question: final variables SCJP6 Correct the following AlinaIoana Oracle Quest Permalink: http://www. final int B = 9. (SCJP6) Correct the following code: Author: AlinaIoana Florea (SCJP6) Correct the following code: class X { X() { System. // line 5 System. final int B. } } Please choose only one answer: • Final variables must be assigned an initial value.a).com/pdf/question-final-variables-scjp6-correct-the-following-alinaioana-oracle (94) Powered by QuizOver.com .quizover.out. System.a). so the final variable "B" from line 1 must receive an initial value at its declaration time • Lines 2 and 4 must be removed as final variables can not be reassigned • Line 5 must be removed as is not allowed to modify the object referred by a final reference variable Check the answer of this question online on QuizOver. // line 3 } public class Test { public static void main(String[] args) { final X x = new X().out. quizover.out.print(a). static int a.b + X.println(a + "" + x. // line 1 a=4. System. } int a. System. nor can it be called directly on class X • The print lines inside main() will produce a compile-time error due to the quotes added to integer variables • Static variables must be given a default value at their declaration time Check the answer of this question online on QuizOver." inside the constructor X() • line 2 .out.com/pdf/how-to-write-java-non-static-variables (95) Powered by QuizOver.print(a).com: Question: how to write java non static variables? Permalink: http://www.inside a method there can be only "final" and "default" variables.26.println(b + "" + x.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved ."a" is not static inside X so it can not be called directly in a static context/main().out.quizover.4.1.out.b).com QuizOver. System.print(b). } public class Test extends X { public static void main(String[] args) { X x = new X(). so line 1 should be removed • line 1 .it would anyway not be allowed to define another "int a. } } Please choose all the answers that apply: • line 1 .out.com . // line 2 System.http://www. (SCJP 6) Find the errors in: Author: AlinaIoana Florea (SCJP 6) Find the errors in: class X { X() { System. static int b.a + X.a). Chapter: Interfaces and Abstract Classes 1.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Interfaces and Abstract Classes Questions (96) Powered by QuizOver.com QuizOver.com .http://www.quizover. // line 3 void method1() . this is a correct and free of error declaration • No..http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . method method1() should be declared public abstract • No.quizover.1. Author: Yasser Ibrahim Is the following declaration for interface Bendable correct and free of compilation error? abstract interface Bendable { // line 1 final int x = 2009.quizover. compilation error at line 1 . compilation error at line 6 .com QuizOver. // line 5 public static class Angle {} // line 6 } Please choose only one answer: • Yes. compilation error at line 5 . x should be declared public final • No.. can't declare a class inside an interface Check the answer of this question online on QuizOver. Is the following declaration for interface Bendable correct and fre.com . abstract should be removed • No.4.com: Question: How to declare a class inside an interface in java? Permalink: http://www.1.com/pdf/how-to-declare-a-class-inside-an-interface-in-java (97) Powered by QuizOver. compilation error at line 3 . http://www. Author: Yasser Ibrahim Is the following declaration for interface Bendable correct and free of compilation error? abstract interface Bendable { // line 1 final int x = 2009..com: Question: How to declare java interface? Permalink: http://www. compilation error at line 3 . x should be declared public final • No. method method1() should be declared public abstract Check the answer of this question online on QuizOver. // line 3 void method1(). this is a correct and free of error declaration • No..quizover. compilation error at line 1.com QuizOver. Bendable should be declared public abstract • No. // line 5 } Please choose only one answer: • Yes.1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .2. Is the following declaration for interface Bendable correct and fre.4.com . compilation error at line 5 .com/pdf/how-to-declare-java-interface (98) Powered by QuizOver.quizover. com .quizover. // line 5 } Please choose only one answer: • Yes. compilation error at line 5 Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .3.1. compilation error at line 1 • No.http://www. Is the following declaration for interface Bendable correct and fre.. Author: JavaChamp Team Is the following declaration for interface Bendable correct and free of compilation error? abstract interface Bendable { // line 1 final int x = 2009. this is a correct and free of error declaration • No. compilation error at line 3 • No. // line 3 void method1(){}..com/pdf/what-are-java-interface-legal-declaration-rules (99) Powered by QuizOver.com: Question: What are java interface legal declaration rules? Permalink: http://www.com QuizOver.quizover.4. ").4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover..com .out. Will the following code compile correctly? Author: Yasser Ibrahim Will the following code compile correctly? abstract class AirPlane { abstract void fly().com QuizOver.1.out. } } Please choose only one answer: • Yes.").print("Flying. because at line 5 method land() must be abstract since class AirPlane is abstract • No.quizover. void land() { // line 5 System.com/pdf/how-to-extend-java-abstract-class (100) Powered by QuizOver..print("Landing.com: Question: How to extend java abstract class? Permalink: http://www.4. because at line 14 AirJet constructor is calling the super() while AirPlane has no constructor defined Check the answer of this question online on QuizOver.http://www. it will compile with no errors • No. // line 14 } void fly() { System. because class AirJet must override method land() • No. } } class AirJet extends AirPlane { AirJet() { super(). quizover. } } class AirJet extends AirPlane { // line 10 AirJet() { super().4. The following code contains a compilation error . // line 20 } Please choose all the answers that apply: • Remove abstract from line 20 and add body to method land() • Declare class AirJet as abstract to at line 10 • Remove super() call at line 13 • Remove abstract at line 1 and line 2 Check the answer of this question online on QuizOver.independently? abstract class AirPlane { // line 1 abstract void fly().com QuizOver.").1.com ..http://www.print("Landing.out. // line 2 void land() { System..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . // line 13 } void fly() { System. } abstract void land() .com: Question: Extending java abstract class Permalink: http://www..com/pdf/extending-java-abstract-class (101) Powered by QuizOver. what can be done .out.quizover.print("Flying.."). what can be done to fix this error .5. Author: Yasser Ibrahim The following code contains a compilation error . 6.com .com: Question: Rules of declaring java abstract Class Permalink: http://www.http://www.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/rules-of-declaring-java-abstract-class (102) Powered by QuizOver.quizover. it must contain at least one abstract method • If a class is declared abstract .1. all its methods must be abstract • A method can either be final or abstract • If a method is abstract then its class must be declared abstract • An Abstract method has no body and ends with a semicolon Check the answer of this question online on QuizOver.com QuizOver.quizover. Which of the following is true? Author: Yasser Ibrahim Which of the following is true? Please choose all the answers that apply: • If a class is declared abstract . com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: How to declare variables inside java interface? Permalink: http://www. Which of the following variables is incorrectly declared? Author: JavaChamp Team Which of the following variables is incorrectly declared? public abstract interface Bouncable { int a = 0.1.com QuizOver. public static final int f = 3.quizover.com .7. public int b = 1.com/pdf/how-to-declare-variables-inside-java-interface (103) Powered by QuizOver.4. public static int c = 2. public final int e = 3. public static transient int d = 3. } Please choose only one answer: • a • b • c • d • e • f Check the answer of this question online on QuizOver.http://www.quizover. public final void test2() {}.com .quizover.com: Question: How to declare java abstract method? Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } Please choose only one answer: • test1 .http://www. test4 and test5 • test1 . test4 and test5 Check the answer of this question online on QuizOver. public abstract final void test5().quizover.1. Three of the methods are incorrectly declared.4.com QuizOver. public static void test3() {}.8. public abstract static void test4().com/pdf/how-to-declare-java-abstract-method (104) Powered by QuizOver. which are they? public abstract class Tester { public void test1(). which are they? Author: JavaChamp Team Three of the methods are incorrectly declared. test2 and test4 • test2 . } char convertToChar(). } public int convertToInt() { return 0. } } • abstract class Digit implements Convertable { int convertToInt() .9. which of the following code segments will compile? public interface Convertable { int convertToInt(). Author: Yasser Ibrahim Considering the following declaration for interface Convertable. char convertToChar(). wh. } } abstract class Digit implements Convertable { public int convertToInt() { return 0.com . Considering the following declaration for interface Convertable. char convertToChar()..com QuizOver.http://www.quizover. } char convertToChar() { (105) Powered by QuizOver. } Please choose all the answers that apply: • class Digit implements Convertable { public char convertToChar() { return 0.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1..4. } class Digit implements Convertable { int convertToInt() { return 0. } • abstract class Digit implements Convertable { • • public int convertToInt() { return 0. com QuizOver.com: Question: What are the rules to implement an interface? Permalink: http://www.quizover.• return 0.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } } interface Roundable extends Convertable { int roundUp().com . } Check the answer of this question online on QuizOver.com/pdf/what-are-the-rules-to-implement-an-interface (106) Powered by QuizOver.quizover. quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: How to declare java abstract class? Permalink: http://www. Which of the following declaration will compile without errors? Author: JavaChamp Team Which of the following declaration will compile without errors? Please choose all the answers that apply: • public abstract class Digit { public abstract void print().4.quizover.10. } • public abstract class Digit { public abstract void print(){} } • public abstract class Digit { public void print().com QuizOver. } • public class Digit { public abstract void print().com .http://www.} • public class Digit { public void print(){}.com/pdf/how-to-declare-java-abstract-class (107) Powered by QuizOver.1.} Check the answer of this question online on QuizOver. Which of the following is correct about an interface in java? Author: Yasser Ibrahim Which of the following is correct about an interface in java? Please choose all the answers that apply: • An Interface can declare data members but must be constants • All methods in an interface are implicitly abstract • Methods in an interface may be public.http://www.1. private. • An interface can implement an abstract class • An interface can be final Check the answer of this question online on QuizOver. protected.quizover.4.com .11.com/pdf/how-to-write-an-interface (108) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: how to write an interface? Permalink: http://www.quizover.com QuizOver. // line 1 void m2().http://www.12.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved ..4. what can..quizover.com/pdf/how-to-implement-an-interface-in-java (109) Powered by QuizOver.com . what can be done independently : interface Movable { public abstract void m1().com QuizOver. // line 3 abstract void m4(). To resolve the compilation error(s) in the following code.1. // line 4 } class Chair implements Movable { // line 5 public void m1() {} // line 6 void m2() {} // line 7 } Please choose all the answers that apply: • mark class Chair "abstract" • mark Chair "abstract" and mark m2() "public" • implement m3() and m4() in Chair (with public access modifier) • implement the methods m3() and m4() in Chair (with public access modifier) and mark m2() in Chair "public" Check the answer of this question online on QuizOver. Author: Yasser Ibrahim To resolve the compilation error(s) in the following code. // line 2 public void m3().quizover.com: Question: how to implement an interface in java? Permalink: http://www. 4.1.13. What is the correct output? Author: MrDick What is the correct output? public interface Father { public void go(); } public interface Mother { public void go(); } class Test implements Father, Mother { // line 1 @Override public void go(){ // line 2 System.out.println("Child"); } public static void main(String args[]) { new Test().go(); // line 3 } } Please choose only one answer: • Compilation error in line 1 • compliation error in line 2 • Child • compilation error in line 3 Check the answer of this question online on QuizOver.com: Question: java interfaces Permalink: http://www.quizover.com/pdf/java-interfaces (110) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.14. Correct the following code: Author: AlinaIoana Florea Correct the following code: interface Pet { int MAX_PET_NR = 10; void play(); } interface Dressable { void dress(); } interface Animal {} // line 1 abstract class Dog extends Animal, Dressable, Pet // line 2 { public void play(int min){} void dress(){} // line 3 void bark(){} } class Bulldog extends Dog implements Pet { Dog dog; Dog dog1 = new Dog(); // line 4 Dog dog2 = new Bulldog(); void bark() throws RuntimeException // line 5 { MAX_PET_NR = 2; // line 6 }; // line 5 } Please choose all the answers that apply: • line 1 - a class(abstract or concrete) can not be empty • line 2 - interfaces must be "implemented" by non-interface classes, and "extended" only by other interfaces • line 3 - to be a valid implementation/override, dress() must stay at least the same as available, so it must keep the "public" access with which was marked automatically in its interface • line 4 - is not ok as Dog is abstract so might not contain fully implemented methods from which to create a whole object. Also Bulldog has to implement play() as the version inherited from Dog is an overload not an override. • line 5 - to be a valid override barck() may not throw any exception if the class it overrides doesn't throw an exception. Nor is it valid for Bulldog to extend again Pet as it inherits it already from Dog. Check the answer of this question online on QuizOver.com: Question: how to implement java interfaces? Permalink: http://www.quizover.com/pdf/how-to-implement-java-interfaces (111) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved (112) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4. Chapter: Exceptions 1. Exceptions Questions (113) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.1. What is the expected output? Author: JavaChamp Team What is the expected output? import java.io.IOException; class Father { public Father() throws IOException { System.out.print("Father"); throw new IOException(); } } class Son extends Father { public Son() throws IOException { System.out.print("Son"); } } public class Tester { public static void main(String[] args) { try { new Son(); } catch (IOException e) { System.out.print("Inside catch"); } } } Please choose only one answer: • Compile error, constructors can't throw Exceptions • FatherSon • FatherInside catch • Father, then an IOException is thrown • Son • SonInside catch Check the answer of this question online on QuizOver.com: Question: Catching java exceptions Permalink: http://www.quizover.com/pdf/catching-java-exceptions (114) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.2. What is the expected output of compiling and running this code? Author: Yasser Ibrahim What is the expected output of compiling and running this code? class Father { public Father() throws RuntimeException { System.out.print("Father"); throw new RuntimeException(); } } class Son extends Father { public Son() throws RuntimeException { System.out.print("Son"); } } public class Tester { public static void main(String[] args) { new Son(); // line 17 } } Please choose only one answer: • Compile error, an import to java.lang.RuntimeException is required • Father will be printed then a RuntimeException would be thrown • Compile error at line 17, new Son() should be within a try/catch block • Son • SonFather • FatherSon Check the answer of this question online on QuizOver.com: Question: How to handle java unchecked exceptions? Permalink: http://www.quizover.com/pdf/how-to-handle-java-unchecked-exceptions (115) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved 4.1.3. What is the expected result of compiling and running the following ... Author: Yasser Ibrahim What is the expected result of compiling and running the following code? import java.io.IOException; class AirPlane { public AirPlane() { System.out.print("AirPlane"); } } class AirJet extends AirPlane { public AirJet() throws IOException { try { throw new IOException(); } catch (IOException e) { System.out.print("IOException is thrown in AirJet"); } } } public class Tester { public static void main(String args[]) { try { new AirJet(); } catch (IOException e) { System.out.print("IOException is thrown in Tester"); } } } Please choose only one answer: • "AirPlaneIOException is thrown in AirJetIOException is thrown in Tester" will be printed • "AirPlaneIOException is thrown in AirJet" will be printed • "AirPlaneIOException is thrown in Tester" will be printed • Compilation error Check the answer of this question online on QuizOver.com: Question: How to catch java exceptions? Permalink: http://www.quizover.com/pdf/how-to-catch-java-exceptions (116) Powered by QuizOver.com - http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved IOException.com: Question: Can java constructors throw exceptions? Permalink: http://www. Author: JavaChamp Team What is the expected output of compiling and running the following code? import java.4.4.println("AirPlane").quizover. } } class AirJet extends AirPlane { } // line 7 public class Tester { public static void main(String args[]) throws IOException { // line 10 new AirPlane().http://www. main() must throw also RuntimeException • Compile error at line 11 ..com QuizOver. // line 11 } } Please choose only one answer: • AirPlane • Compile error at line 7. What is the expected output of compiling and running the following .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . RuntimeException { System. class AirPlane { public AirPlane() throws IOException.com/pdf/can-java-constructors-throw-exceptions (117) Powered by QuizOver. AirJet must declare a constructor that throws IOException or any of its supertypes • Compile error at line 10.com .1.new AirPlane() must be within try/catch block Check the answer of this question online on QuizOver.out.quizover.io.. http://www.com . } class Paper implements Foldable { public void fold() { // line 6 System. } } public class Tester { public static void main(String args []) { Foldable obj1 = new Paper().com: Question: How to usea try catch in java? Permalink: http://www.fold().com QuizOver. What is the expected output? Author: Yasser Ibrahim What is the expected output? interface Foldable { public void fold() throws Exception . fold() must declare at header throws Exception • Compilation error at line 8. obj1.quizover.quizover.com/pdf/how-to-usea-try-catch-in-java (118) Powered by QuizOver.fold().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . // line 10 obj2.1.out.5.print("Fold"). unhandled exception Check the answer of this question online on QuizOver. } } Please choose only one answer: • FoldFold • Compilation error at line 6.4. // line 8 Paper obj2 = new Paper(). unhandled exception • RuntimeException at line 8 • Compilation error at line 10. out.out.com: Question: How to declare try catch finally block in java? Permalink: http://www. System.com/pdf/how-to-declare-try-catch-finally-block-in-java (119) Powered by QuizOver.1.print("1").4. } } } Please choose only one answer: • 123 • 12 • Compilation error .com .http://www.quizover.exit(0).6.com QuizOver.print("2"). there should be at least one catch before finally Check the answer of this question online on QuizOver.print("3"). try { System.out.quizover. } finally { System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { System. } } Please choose only one answer: • 1234 • 13 • 1 • Compilation error Check the answer of this question online on QuizOver.com QuizOver.http://www.com/pdf/try-catch-finally-block-in-java (120) Powered by QuizOver. } System.com: Question: try catch finally block in java Permalink: http://www.quizover. } catch (Exception e) { System.1.out.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { System.quizover.7.print("2"). try { return.print("1").4.com .out.out. } finally { System.print("4").print("3"). } catch (Exception e) { System.out.println("ArithmeticException").out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. } } } Please choose only one answer: • "RuntimeException" is printed • "Exception" is printed • "ArithmeticException" is printed • Compilation error Check the answer of this question online on QuizOver.println("Exception").8.com: Question: How to write java try catch statement? Permalink: http://www. What is the result of compiling and running the following program? Author: JavaChamp Team What is the result of compiling and running the following program? public class Tester { public static void main(String[] args) { try { throw new RuntimeException().com .http://www.quizover.1.println("RuntimeException"). } catch (ArithmeticException e) { System.quizover.out. } catch (RuntimeException e) { System.4.com/pdf/how-to-write-java-try-catch-statement (121) Powered by QuizOver. print("finally"). } } } } Please choose only one answer: • "exception" is printed • "finally" is printed • "exceptionfinally" is printed • Compilation error Check the answer of this question online on QuizOver. } finally { System.1.com: Question: How to write java nested try catch? Permalink: http://www.quizover.com .quizover.out.com/pdf/how-to-write-java-nested-try-catch (122) Powered by QuizOver. } catch (Exception ex) { System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static void method() throws Exception { throw new Exception().4.out.print("exception"). } catch (Throwable e) { try { throw new Exception() .http://www. } public static void main(String[] args) { try { method().9. com . What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { static void method(){ throw new Exception().out.4.com: Question: How to write nested try catch in java? Permalink: http://www. } public static void main(String[] args) { try { method().http://www.print("finally").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover. } catch (Throwable e) { try { throw new Exception() . } finally { System.quizover. } catch (Exception ex) { System.out.print("exception").10.com/pdf/how-to-write-nested-try-catch-in-java (123) Powered by QuizOver. } } } } Please choose only one answer: • exception • finally • exceptionfinally • Compilation error Check the answer of this question online on QuizOver.com QuizOver.1. Date. // line 12 Date parse = df.createNewFile(). // line 6 } public static void main(String[] args) { call(). public class Tester { static void call() { // line 3 File file = new File("javachamp.quizover.quizover.DateFormat.com .parse("12.1.getDateInstance().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .File. what of the following possible solutions (made together) can be done to remove these errors.com/pdf/how-to-handle-exceptions-in-java (124) Powered by QuizOver.com QuizOver. what of the followi. // line 5 throw new IllegalArgumentException(). Author: JavaChamp Team The following code contains compilation errors.2009").11. import java. // line 13 } } Please choose all the answers that apply: • Add throws IOException declaration to call() at line 3 • Add throws FileNotFoundException declaration to call() at line 3 • Add throws IllegalArgumentException declaration to call() at line 3 • Surround code from line 11 to 13 with try {} catch (IOException e) {} block • Surround code from line 11 to 13 with try {} catch (Exception e) {} block Check the answer of this question online on QuizOver.dat"). The following code contains compilation errors..util. // line 11 DateFormat df = DateFormat..http://www. putting in mind that all necessary imports will be added automatically? import java. import java.text.io.4.11. //line 4 file.com: Question: how to handle exceptions in java? Permalink: http://www. print(x).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } finally { System.12.1.com QuizOver. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { String stmt = "javachamp 2009".com .http://www.quizover.out.4. System.com/pdf/how-to-handle-exceptions-using-trycatch-block (125) Powered by QuizOver.quizover.split(" "). try { int x = Integer. String[] arr = stmt. } } } Please choose only one answer: • 2009 • finally • 2009finally • No output will be produced • Compilation error Check the answer of this question online on QuizOver.com: Question: How to handle exceptions using try/catch block? Permalink: http://www.parseInt(arr[1]).print("finally").out. try { int x = Integer. } finally { System.print(x).com .split(" ").1.com/pdf/how-to-write-try-catch-statement-in-java (126) Powered by QuizOver.out.quizover.parseInt(arr[0]).out.com: Question: How to write try catch statement in java? Permalink: http://www.com QuizOver.quizover. } } } Please choose only one answer: • 2009 • 2009finally • catchfinally • No output will be produced • Compilation error • 2009catchfinally Check the answer of this question online on QuizOver.print("finally"). } catch (Exception e) { System.4.13. System.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. String[] arr = stmt. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { String stmt = "javachamp 2009".print("catch"). 4.com .1.quizover.14.quizover. In which case a NoClassDefFoundError will be thrown? Author: JavaChamp Team In which case a NoClassDefFoundError will be thrown? Please choose only one answer: • When try to compile a non found java file • When try to run a non found java .class file • When try to compile a non found java file or try to run a non found java .class file Check the answer of this question online on QuizOver.com: Question: When java NoClassDefFoundError is thrown? Permalink: http://www.com/pdf/when-java-noclassdeffounderror-is-thrown (127) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.http://www. } finally { System.15.com/pdf/how-does-division-by-zero-with-doubles-work-pedro-kowalski (128) Powered by QuizOver.0.quizover.quizover.println("EXCEPTION!").println(d).com: Question: how does division by zero with doubles work pedro kowalski Permalink: http://www. } } } Please choose only one answer: • NotANumber • NaN • EXCEPTION! -4.com .0 • Compilation fails Check the answer of this question online on QuizOver.0 • -Infinity • EXCEPTION! 0.http://www. } catch (ArithmeticException e) { System.1. try { d /= 0.com QuizOver.out.out. What is the output of the following code Author: Pedro Kowalski What is the output of the following code public class Tester { public static void main(String[] args) { Double d = -4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. quizover.com QuizOver.http://www. Inheritance Questions (129) Powered by QuizOver.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. Chapter: Inheritance 1. com QuizOver.http://www. Super is already implementing it • No there is a compilation error at line 4. if you knew that they are .com .com: Question: How to extend or implement in java? Permalink: http://www. the declarations are correct • No there is a compilation error at line 2.quizover.1.1. must implements not extends • No there is a compilation error at line 4.. extends should come before implements Check the answer of this question online on QuizOver.quizover. Are the following declarations correct. Author: JavaChamp Team Are the following declarations correct.4.com/pdf/how-to-extend-or-implement-in-java (130) Powered by QuizOver.. if you knew that they are in the same package? interface Bouncable{ } // line 1 interface Colorable extends Bouncable{ } // line 2 class Super implements Colorable{ } // line 3 class Sub implements Colorable extends Super { } // line 4 Please choose only one answer: • Yes. over implementing for interface Colorable.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . com/pdf/how-to-implement-or-extend-in-java (131) Powered by QuizOver.1. Which of the following is true? Author: JavaChamp Team Which of the following is true? Please choose all the answers that apply: • A class can extend more than one class • A class can extend only one class but many interfaces • An interface can extend many interfaces • An interface can implement many interface • A class can extend one class and implement many interfaces Check the answer of this question online on QuizOver.quizover.com QuizOver.2.com: Question: How to implement or extend in java? Permalink: http://www.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.http://www.com . out.//line 5 } } Please choose only one answer: • All lines will evaluate to true • All lines will evaluate to true and only line 4 will evaluate to false • Only line 1 and 2 will evaluate to true (132) Powered by QuizOver.println(new Sub() instanceof Bouncable).com QuizOver.println(new Sub() instanceof Colorable).out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .//line 2 System.out.http://www.println(new Sub() instanceof Super).com . //line 1 System. Which lines will evaluate to true? Author: Yasser Ibrahim Which lines will evaluate to true? interface Colorable { } interface Bouncable extends Colorable { } class Super implements Bouncable { } class Sub extends Super implements Bouncable { } public class Tester { public static void main(String[] args) { System.out.4.println(new Super() instanceof Colorable).println(new Super() instanceof Sub).//line 3 System.out.1.//line 4 System.3.quizover. com: Question: How to use java instanceof? Permalink: http://www.quizover.http://www.com/pdf/how-to-use-java-instanceof (133) Powered by QuizOver.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .• Lines 3 and 5 will evaluate to false Check the answer of this question online on QuizOver.quizover.com QuizOver. com . System.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. System.com/pdf/how-to-use-instanceof-java (134) Powered by QuizOver.4. System.print(new Sub() instanceof Super).http://www.print(new Sub() instanceof Colorable).print(new Individual() instanceof Super).com QuizOver.print(new Super() instanceof Sub).out. } } Please choose only one answer: • truetruefalsefalse • truefalsefalsefalse • Compilation error • RuntimeException becaue of the print statemen Check the answer of this question online on QuizOver.out.quizover.1. what is the result of compiling and running the following code? Author: JavaChamp Team what is the result of compiling and running the following code? interface Colorable { } interface Bouncable extends Colorable { } class Super implements Bouncable { } class Sub extends Super implements Bouncable { } class Individual { } public class Tester { public static void main(String[] args) { System.com: Question: how to use instanceof java? Permalink: http://www.4.out. 1. what is the output? Author: Yasser Ibrahim Will the following code compile and if yes . Colorable i = (Colorable) a.5. Vehicle b = new Vehicle(). Colorable j = (Colorable) b.com .http://www.quizover. Will the following code compile and if yes .4. } } Please choose only one answer: • The code compiles fine and produces no output • The code compiles fine but throws a RuntimeException because of the second casting • There is a compilation error because of the second casting • The code compiles fine but throws a RuntimeException because of the first casting Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. what is the output? interface Colorable {} class Vehicle {} class Car extends Vehicle implements Colorable {} public class Tester { public static void main(String[] args) { Vehicle a = new Car().com: (135) Powered by QuizOver. com .http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.com/pdf/how-to-cast-java-variables (136) Powered by QuizOver.quizover.com QuizOver.Question: How to cast java variables? Permalink: http://www. com QuizOver. Vehicle b = new Vehicle(). } } Please choose only one answer: • The code compiles fine and produces no output • The code compiles fine but throws a RuntimeException because of the second casting • There is a compilation error because of the second casting (137) Powered by QuizOver. Colorable j = (Colorable) b. Would the following code compile and if yes .1.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . what is the output? interface Colorable {} class Vehicle {} class Car extends Vehicle implements Colorable {} public class Tester { public static void main(String[] args) { Vehicle a = new Car().6. what is the output? Author: Yasser Ibrahim Would the following code compile and if yes .4.http://www. Colorable i = (Colorable) a.com . com: Question: casting objects in java Permalink: http://www.quizover.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/casting-objects-in-java (138) Powered by QuizOver.com .quizover.Check the answer of this question online on QuizOver.com QuizOver. } } class SubCategory extends Category { SubCategory() { System. What is the output of compiling and running the following program? Author: Yasser Ibrahim What is the output of compiling and running the following program? class Category { Category() { System.print("SubCategory_").http://www.out.com: Question: Order of constructor calls of java derived classes Permalink: http://www.com/pdf/order-of-constructor-calls-of-java-derived-classes (139) Powered by QuizOver.out. } } class SubSubCategory extends SubCategory { SubSubCategory() { System.print("Category_").com QuizOver.1.out. } } Please choose only one answer: • SubSubCategory_SubCategory_Category_ • SubSubCategory_ • Category_SubCategory_SubSubCategory_ Check the answer of this question online on QuizOver.4. } } public class Tester { public static void main(String[] args) { new SubSubCategory().print("SubSubCategory_").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.7.com .quizover. out. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? interface Chewable {} interface Eatable extends Chewable{} class Food implements Chewable { } class Meat extends Food {} class Gum implements Chewable{} public class Tester { public static void main(String[] args) { Food food = new Food().1. } } Please choose only one answer: • truetruetrutrue • truetruefalsetrue (140) Powered by QuizOver.8. Meat meat = new Meat().http://www.out.print(meat instanceof Food).quizover. System.print(gum instanceof Food).out. System.print(food instanceof Eatable).com . Gum gum = new Gum().4.out.com QuizOver. System.print(gum instanceof Chewable).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . System. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/using-instanceof-in-java (141) Powered by QuizOver.quizover.com: Question: using instanceof in java Permalink: http://www.• • falsetruefalsetrue Compilation error Check the answer of this question online on QuizOver.com .quizover.http://www.com QuizOver. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . System.9.http://www. Meat meat = new Meat().quizover. System.out.print(gum instanceof Chewable).print(meat instanceof Eatable). Gum gum = new Gum().com . System.out.out.com QuizOver.print(gum instanceof Eatable).out.print(food instanceof Chewable). System.1. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? interface Chewable {} interface Eatable extends Chewable{} class Food implements Eatable { } class Meat extends Food {} class Gum implements Chewable{} public class Tester { public static void main(String[] args) { Food food = new Food(). } } Please choose only one answer: • falsetruefalsetrue • truetruefalsetrue (142) Powered by QuizOver.4. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.com QuizOver.• • truetruetruetrue Compilation error Check the answer of this question online on QuizOver.com: Question: How to use instanceof in java? Permalink: http://www.quizover.com/pdf/how-to-use-instanceof-in-java (143) Powered by QuizOver.http://www.com . 10.1.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .http://www. Which of the following statements are correct? Author: JavaChamp Team Which of the following statements are correct? Please choose all the answers that apply: • A class can extend one class and many interfaces • A class can implement one class and many interfaces • A class can extend one class and implements many interfaces • An interface can extend many classes and interfaces • An interface can implement many classes and interfaces • An interface can implement many interfaces • An interface can extend many interfaces Check the answer of this question online on QuizOver.4.quizover.com QuizOver.com/pdf/how-to-implement-interface-or-extend-class-in-java (144) Powered by QuizOver.com: Question: how to implement interface or extend class in java? Permalink: http://www. } } Please choose only one answer: • BaseDerived • DerivedBase • Derived • Base • Compilation error Check the answer of this question online on QuizOver.com QuizOver.print("Derived").com .com: Question: How to write constructor for derived class in java? Permalink: http://www.1.} public static void main(String[] args) { new Derived().quizover.out.com/pdf/how-to-write-constructor-for-derived-class-in-java (145) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.print("Base").quizover.} } public class Derived extends Base { public Derived() {System.http://www. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? class Base { public void Base() {System.4.11. out.12.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .} public void Base(String n) {System.com .} } public class Derived extends Base { public Derived() {System.1.4.print("Base2"). } } Please choose only one answer: • Base1Derived • Base2Derived • Derived • Compilation error Check the answer of this question online on QuizOver.print("Derived").quizover.com: Question: Inheritance and constrcutors in java Permalink: http://www.com QuizOver.http://www.out.} public static void main(String[] args) { new Derived().com/pdf/inheritance-and-constrcutors-in-java (146) Powered by QuizOver.quizover. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? class Base { public Base(String n) {System.out.print("Base1"). out.} public static void main(String[] args) { new Derived().} } public class Derived extends Base { public Derived() {this("JavaChamp").1.13.print(s). What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? class Base { public Base() {System.out.out.com/pdf/how-to-call-this-inside-java-constructor (147) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . System.com .print("Derived").print("Base").4. } } Please choose only one answer: • JavaChampDerived • JavaChampBaseDerived • BaseJavaChampDerived • JavaChampDerivedBase • Compilation error Check the answer of this question online on QuizOver.com QuizOver.quizover.quizover.} public Derived(String s) { System.com: Question: How to call this inside java constructor? Permalink: http://www.http://www. 4. } } public class Tester { public static Bird getIt(Creature c) { System. } } class Falcon extends Bird { String getName() { return "Falcon". . Which statement(s). } } class Bird extends Creature { String getName() { return "Bird".14. } public static void main(String[] args) { // insert code here } } (148) Powered by QuizOver.getName()). return (Bird) c.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . will compile? class Creature { String getName() { return "Creature".com .. Author: Yasser Ibrahim Which statement(s).com QuizOver.out. inserted independently at // insert code here..quizover.println(c.1. inserted independently at // insert code here.http://www. com . Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . • getIt(new Object()).com/pdf/when-java-classcastexception-is-thrown (149) Powered by QuizOver.Please choose all the answers that apply: • getIt(new Creature()).com QuizOver.http://www.com: Question: When java classCastException is thrown? Permalink: http://www.quizover.quizover. • getIt(new Bird()). • getIt(new Falcon()). where could possibly be the.http://www. Bird b1 = (Bird) c1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . // Line 1 Bird b2 = (Falcon) c2.quizover.15. where could possibly be the compilation error(s)? class Creature {} class Bird extends Creature {} class Falcon extends Bird {} public class Tester { public static void main(String[] args) { Creature c1 = new Creature(). // Line 5 Falcon f1 = b4. // Line 6 } } Please choose all the answers that apply: • Line 1 • Line 2 • Line 3 • Line 4 • Line 5 (150) Powered by QuizOver. Author: JavaChamp Team The following program fails to compile. The following program fails to compile.com .4. // Line 2 Bird b3 = c2. // Line 3 Bird b4 = new Falcon(). // Line 4 Bird b5 = (Bird) new Creature(). Creature c2 = new Bird().1...com QuizOver. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .com: Question: How to cast in java? Permalink: http://www.• Line 6 Check the answer of this question online on QuizOver.http://www.quizover.quizover.com QuizOver.com/pdf/how-to-cast-in-java (151) Powered by QuizOver. will compile? class Creature { void grow() { } } class Bird extends Creature { void fly() { } } class Falcon extends Bird { void hunt() { } } public class Tester { public static void main(String[] args) { Creature c1 = new Bird().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . will compile? Author: Yasser Ibrahim What inserted.com . independently at // insert code here . // insert code here } } (152) Powered by QuizOver.1. What inserted. independently at // insert code here . Falcon c2 = new Falcon().quizover.16.http://www.4.com QuizOver. com: Question: Casting rules in java Permalink: http://www.http://www.com QuizOver.Please choose all the answers that apply: • c1.hunt(). • ((Bird)c1).quizover.grow().com .fly(). • c1.quizover. • ((Falcon)c1).com/pdf/casting-rules-in-java (153) Powered by QuizOver. Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .fly(). com ..17. What inserted.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . independently at // insert code here .4. Author: JavaChamp Team What inserted. independently at // insert code here .com QuizOver. // insert code here } } (154) Powered by QuizOver.1. will compile .http://www.quizover. will compile and run with no errors and exceptions? class Creature { void grow() { } } class Bird extends Creature { void fly() { } } class Falcon extends Bird { void hunt() { } } public class Tester { public static void main(String[] args) { Creature c1 = new Bird().. Falcon c2 = new Falcon(). hunt(). • ((Falcon)c1).com: Question: How to java cast? Permalink: http://www.com QuizOver.Please choose all the answers that apply: • c1.quizover.fly().grow().fly().http://www.com . Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/how-to-java-cast (155) Powered by QuizOver. • c1. • ((Bird)c1).quizover. Please choose only one answer: • true • false • compilation error • NullPointerException is thrown at runtime Check the answer of this question online on QuizOver.4. Author: JavaChamp Team considering AnyClassOrInterface is a class or an interface in java what would the following statement print? System.com/pdf/null-and-instanceof-in-java (156) Powered by QuizOver.com: Question: null and instanceof in java Permalink: http://www.http://www.out.18.quizover.print(null instanceof AnyClassOrInterface )..com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.1.com . considering AnyClassOrInterface is a class or an interface in java .. .http://www.com .println("hello 1").out. args){ System..quizover.1. Check the answer of this question online on QuizOver.println("Hello").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .19. } } class InitDemo extends A{ A ob=new A().4.println("Hello 2").out. InitDemo(){ System. What is the output ? Author: Nikhil Kumar What is the output ? class A{ A(){ System. } public static void main(String.out.com/pdf/inheritance-in-java-nikhil-kumar (157) Powered by QuizOver. } } Please choose only one answer: • Hello 2 hello 1 Hello Hello • Hello 2 Hello Hello hello 1 • Hello 2 Hello hello 1 Hello • Exception is thrown at runtime.com QuizOver.com: Question: inheritance in java Nikhil Kumar Permalink: http://www.quizover. new InitDemo(). com .http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Chapter: Arrays 1.com QuizOver. Arrays Questions (158) Powered by QuizOver.quizover.4. com QuizOver. it is a.quizover.http://www.out.1.length() not a.com: Question: how to declare java array? Permalink: http://www.print(a.com/pdf/how-to-declare-java-array (159) Powered by QuizOver.length Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.1. } Please choose only one answer: • 0 • Compilation error.quizover. arrays cannot be initialized to zero size • Compilation error.length). What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public static void main(String[] args) { int[] a = new int[0].com . System. out.com . test(a). a = b.out.print(a.2. System.print(b.length). What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static void test(int[] a) { int[] b = new int[2]. System.quizover.com QuizOver.1.print(a. System.com: Question: array size in java Permalink: http://www.http://www.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .length).4.com/pdf/array-size-in-java (160) Powered by QuizOver. } public static void main(String[] args) { int[] a = new int[5]. } } Please choose only one answer: • 225 • 255 • 200 • 222 Check the answer of this question online on QuizOver.quizover.length). 4.http://www.com QuizOver. int count=0."entry2"}. What is true after running the following code? Author: JavaChamp Team What is true after running the following code? public static void main(String[] args) { String entries[] = {"entry1".quizover. while (entries [count++]!=null){ System.com/pdf/when-arrayindexoutofboundsexception-is-thrown (161) Powered by QuizOver. } System.println(count).com: Question: When ArrayIndexOutOfBoundsException is thrown? Permalink: http://www.quizover.1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.3.out. } Please choose all the answers that apply: • An Exception will be thrown • 0 will be printed as part of the output • 2 will be printed as part of the output • 3 will be printed as part of the output Check the answer of this question online on QuizOver.println(count).com . int b[3].quizover. Which of the following declarations of an array is incorrect? Author: Yasser Ibrahim Which of the following declarations of an array is incorrect? public static void main(String[] args) { int[] a[].com QuizOver.http://www.com/pdf/array-declaration-in-java (162) Powered by QuizOver.4.com: Question: Array declaration in java Permalink: http://www. int[] d[].com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } Please choose only one answer: • a • b • c • d Check the answer of this question online on QuizOver. int []c[].quizover.4.com .1. com: Question: When java ArrayIndexOutOfBoundsException is thrown? Permalink: http://www.com .http://www.quizover.4. if (x <= 10) System.5.quizover. } } Please choose only one answer: • Compilation error • ArrayIndexOutOfBoundsException is thrown • javachamp • No output is produced Check the answer of this question online on QuizOver.x[5].println("javachamp").com QuizOver.com/pdf/when-java-arrayindexoutofboundsexception-is-thrown (163) Powered by QuizOver. public static void main(String[] args) { final int x = new Tester().1.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following program? Author: JavaChamp Team What is the result of compiling and running the following program? public class Tester { final static int x[] = new int[5]. byte b2=45.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Author: VenkaTESH POLNEEDI public static void main(String[] args) { byte b1= 25.com: Question: type mismatch cannot convert from int to byte Permalink: http://www.4. byte b2=45. } Please choose only one answer: • a)70 • b)CompileError • c)25 • d)RunTimeException Check the answer of this question online on QuizOver.http://www.. public static void main(String[] args) { byte b1= 25.com/pdf/type-mismatch-cannot-convert-from-int-to-byte (164) Powered by QuizOver.quizover..6.com QuizOver.com .quizover.1. byte b3= b1+b2. Only Invocation i will throw an exception.com .7. Check the answer of this question online on QuizOver.Invocation ii will produce he output 12.com QuizOver.. • D.java Arrays ..Invocation iii will produce he output 12 32. Invocations ii and iii will throw exceptions.com/pdf/java-commandline-invocation (165) Powered by QuizOver.out.){ System. • E.java Arrays ii. } } } Please choose all the answers that apply: • A. Author: Waduge Livera Consider the following command-line invocations? i.args.length>x++.1. Consider the following command-line invocations? i.quizover. • C.http://www.4.java Arrays 12 32 class Arrays { public static void main(String [ ] args){ for(int x=0.Only the invocation i will complete without throwing exceptions • B.com: Question: java command-line invocation Permalink: http://www.java Arrays 12 iii.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .print(args[x]+ " "). Compilation fails because of an error in line 13. A ClassCastException is thrown at runtime.quizover. // line 12 int[] someArray = (int[])obj. • D.com .4.8.http://www. 2. 1 2 3 • B. Check the answer of this question online on QuizOver. Compilation fails because of an error in line 12.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result? Author: Vinay K What is the result? public static void main(String[] args) { Object obj = new int[] { 1. // line 14 } Please choose only one answer: • A.quizover.com QuizOver.com: Question: java array casting Permalink: http://www.1.com/pdf/java-array-casting (166) Powered by QuizOver. • E. 3 }.print(i + " ").out. // line 13 for (int i : someArray) System. • C. Compilation fails because of an error in line 14. equals("debug")) { System.4.quizover.println("Release").com/pdf/how-to-implement-java-arrays-and-command-line-arguments (167) Powered by QuizOver..http://www.out.. What is the result of running the following code with "java Test de.com: Question: how to implement java arrays and command line arguments? Permalink: http://www.com . Author: AlinaIoana Florea What is the result of running the following code with "java Test debug": class Test { public static void main(String [ ] args) { if (args.println(args[0]).length == 1 | args[1].com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. } } } Please choose only one answer: • Debug • Release • Compilation fails • An exception is thrown at run-time Check the answer of this question online on QuizOver.1.out.quizover. } else { System.9. quizover.com QuizOver.com .4.http://www. Chapter: Operators 1. Operators Questions (168) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { static int i . private static int increment(int i) { return i++. } public static void main(String[] args) { System.4.com: Question: Incrementing java static variable Permalink: http://www.com .print(i).http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } public Tester() { i = 1.1. } } Please choose only one answer: • 01 • 00 • 12 • Compilation error Check the answer of this question online on QuizOver.out.out.quizover.print(i = increment(i)). System.quizover.com QuizOver.com/pdf/incrementing-java-static-variable (169) Powered by QuizOver.1. Which of the following "if" statement(s) will throw a NullPointerEx.//line 4 } } Please choose all the answers that apply: • Line 1 • Line 2 • Line 3 • Line 4 Check the answer of this question online on QuizOver..quizover.//line 2 if((val==null) | (val.com .4.2.code >0)).code==0)). Author: JavaChamp Team Which of the following "if" statement(s) will throw a NullPointerException (assuming each statement will be executed independently)? public class Tester { public int code.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .//line 3 if((val==null) || (val.com/pdf/how-to-use-java-short-circuit-operators-which-of-the-following-if (170) Powered by QuizOver.com: Question: How to use java short circuit operators Which of the following if Permalink: http://www.code >0)).code==0)).com QuizOver.1.http://www. if((val!=null) & (val. public static void main(String[] args) { Tester val = null.quizover..//line 1 if((val!=null) && (val. print(isEven(3)). } public static void main(String[] args) { System.com/pdf/how-to-use-java-conditional-operators (171) Powered by QuizOver. System.1.quizover.com . } } Please choose only one answer: • truefalsetrue • falsefalsetrue • falsefalsefalse • a compilation error • an exception is thrown at run time Check the answer of this question online on QuizOver.com: Question: How to use java conditional operators? Permalink: http://www.print(isEven(2)).out.4.com QuizOver.3. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static boolean isEven(int x) { return (x % 2 == 0) ? true : false.out.http://www.out.print(isEven(4)). System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover. for (. i > 0. } } Please choose only one answer: • Compilation error • 21 • 20 • 2-1 Check the answer of this question online on QuizOver.quizover. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { int x = 0.1.com .4.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover. System.com: Question: Short circuit vs non shortcircuit operators in java Permalink: http://www. int i = 1.println(x + "" + i).4.http://www.out.com/pdf/short-circuit-vs-non-shortcircuit-operators-in-java (172) Powered by QuizOver. i--) if ((++x > 0) | (--i > 0)) x++. com: Question: short circuit operators in java Permalink: http://www.com QuizOver.http://www.print(x+" "+y).4.out. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { int x = 0. if (false || true | (++y> 0 | y++>0)) System.5.com .out.quizover.com/pdf/short-circuit-operators-in-java (173) Powered by QuizOver. int y = 0. } } Please choose only one answer: • stmt1 stmt2 1 2 • stmt1 stmt2 0 0 • stmt2 1 2 • stmt2 0 2 • 00 Check the answer of this question online on QuizOver. if ((true & false) | (true & false) & x++>0) System.print("stmt2 ").print("stmt1 ").quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1. System.out. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { System.4.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . System.quizover. } } Please choose only one answer: • 99 • 72 9 • 9 72 • 72 72 Check the answer of this question online on QuizOver.com .out.com/pdf/concatenating-operands-in-java (174) Powered by QuizOver.out.print(7 + 2 + " ").http://www.com: Question: Concatenating operands in java Permalink: http://www.print("" + 7 + 2 + " ").6.1. com .com/pdf/java-boolean-logical-operators (175) Powered by QuizOver. int x = 5. System.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.print(!(result > 0) ^ true ^ (flag = false)).print(flag).7. } } Please choose only one answer: • truefalse • truetrue • falsefalse • falsetrue • Compilation error Check the answer of this question online on QuizOver.com QuizOver.out.quizover.4. int result = (8 * 2) % x. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { boolean flag = true. System.com: Question: Java Boolean Logical Operators Permalink: http://www.1.out. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { boolean flag = true.8.com QuizOver.out.4.com: Question: short circuit logical operators in java Permalink: http://www.http://www.print(flag). int x = 5. System.quizover.out. } } Please choose only one answer: • truefalse • truetrue • falsefalse • falsetrue • Compilation error Check the answer of this question online on QuizOver. int result = (8 * 2) % x. System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/short-circuit-logical-operators-in-java (176) Powered by QuizOver.print(!(result > 0) ^ true ^ !(flag = false)).quizover.com .1. com .com: Question: using == in java Permalink: http://www. System.out.out.print(x == z).quizover.4.quizover.1.http://www. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Test{ public static void main(String argv[]) { Foo x = new Foo().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Foo z = x. } } class Foo {} Please choose only one answer: • falsetrue • falsefalse • truetrue • compilation error Check the answer of this question online on QuizOver. Foo y = new Foo().9. System.com QuizOver.com/pdf/using-in-java (177) Powered by QuizOver.print(x == y). com QuizOver.4. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Test{ public static void main(String argv[]) { int a = 6.http://www.quizover.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: if condition in java Permalink: http://www.com .1.out.com/pdf/if-condition-in-java (178) Powered by QuizOver. if (a = 6) System.10.print("true"). } } Please choose only one answer: • no output is produced • true • a compilation error Check the answer of this question online on QuizOver. out. System.out. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: String and + operator in java Permalink: http://www.com/pdf/string-and-operator-in-java (179) Powered by QuizOver.com QuizOver.quizover. System.quizover.com .out. } Please choose only one answer: • 4545459 • 459459 • 45999 Check the answer of this question online on QuizOver.4.print(4 + 5 + "9").11.http://www.print("4" + 5).print(4 + 5).1. print(x + "" + y).12.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.1.com: Question: ++ and -.com QuizOver. x = 5 + ++y.com .com/pdf/-and-in-java (180) Powered by QuizOver.in java Permalink: http://www. } Please choose only one answer: • 6161 • 671 • 5161 Check the answer of this question online on QuizOver. x = 0.http://www.print(x + "" + y).4.out. y = 0. x = 5 + y++. System. System.quizover. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public static void main(String[] args) { int x = 0.quizover. y = 0. out.com . if ((y == x++) && (x < ++y)) {} System.println(x + "" + y).13.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/shortcircuit-and-in-java (181) Powered by QuizOver.1. y = 0.4.com QuizOver.com: Question: short-circuit AND in java Permalink: http://www. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { int x = 1. } Please choose only one answer: • 20 • 21 • 10 • 11 Check the answer of this question online on QuizOver.quizover.http://www. quizover.14.com . } Please choose only one answer: • 10 • 11 • 20 • 21 Check the answer of this question online on QuizOver.4.http://www.com: Question: short-circuit OR in java Permalink: http://www.1.com QuizOver. if ((y == x++) || (x < ++y)) { } System. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { int x = 1.com/pdf/shortcircuit-or-in-java (182) Powered by QuizOver. y = 0.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .println(x + "" + y).quizover. 4. if ((y == ++x) & (x < ++y)) {} System.com QuizOver.http://www.com/pdf/-nonshortcircuit-and-in-java (183) Powered by QuizOver.com: Question: & non-short-circuit AND in java Permalink: http://www.1.com .quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .15.out. y = 0. } Please choose only one answer: • 10 • 11 • 20 • 21 Check the answer of this question online on QuizOver.println(x + "" + y). What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { int x = 0.quizover. com/pdf/-nonshortcircuit-or-in-java (184) Powered by QuizOver.com .16. } Please choose only one answer: • 00 • 10 • 11 • 12 • 22 Check the answer of this question online on QuizOver.out. } System. if ((y == x++) | (x < ++y)) { ++y.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { int x = 0. y = 0.quizover.println(x + "" + y).com: Question: | non-short-circuit OR in java Permalink: http://www.http://www.quizover.4.1.com QuizOver. } Please choose only one answer: • falsefalse • falsetrue • truefalse • truetrue Check the answer of this question online on QuizOver.com QuizOver.quizover.quizover.1.out.com/pdf/logical-operators-and-in-java (185) Powered by QuizOver. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public static void main(String[] args) { System.com .out.17. System.4.com: Question: Logical Operators ^ and ! in java Permalink: http://www.print(false ^ true).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .print(!false).http://www. println(k).http://www.quizover.println(k).com QuizOver.1. System. • It will compile successfully and display 1 followed by 1 and then 2 as an output. System.out.out. k*=k++.com/pdf/java-compound-operator (186) Powered by QuizOver.println(k).com .quizover.com: Question: java compound operator Permalink: http://www.out. • It will compile successfully and display 1 followed by 3 and then 4 as an output. • It will generate compile time error. } } Please choose only one answer: • It will compile successfully and display 1 followed by 2 and then 3 as an output. System. what will be the output when we compile and execute the code below: Author: Pankaj Gupta what will be the output when we compile and execute the code below: class Compound{ public static void main(String args[]) { int k=12. k/=--k.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . k*=++k.4. Check the answer of this question online on QuizOver.18. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. What is the output of the running the following program? Author: JavaChamp Team What is the output of the running the following program? class Test { public static void main(String arg[]) { A b = new B(1000).1.com QuizOver.quizover. } } class C extends A { C(int val) { value = val.com .com/pdf/which-operands-can-be-used-in-the-comparison-operators (187) Powered by QuizOver.http://www. System.19.4. } class B extends A { B(int val) { value = val. } } Please choose only one answer: • "true" then "false" will be printed • "false" then "false" will be printed • "false" then "true" will be printed • compilation error at the first print statement • compilation error at the second print statement Check the answer of this question online on QuizOver.out.println(b==c).quizover. A c = new C(1000).println(b <= c). System.com: Question: which operands can be used in the comparison operators? Permalink: http://www. } } class A { int value. com/pdf/which-operands-can-be-used-in-the-equality-comparison-operators (188) Powered by QuizOver.4. long y = 1000.println(x==y). } } Please choose only one answer: • true then false will be printed • true then true will be printed • false then true wil be printed • false then false will be printed • compilation error at the first print statement • compilation error at the second print statement Check the answer of this question online on QuizOver.println(x==z). Integer z = 1000.quizover.com .out.com: Question: which operands can be used in the equality comparison operators? Permalink: http://www. What is the output of compiling and running the following code? Author: JavaChamp Team What is the output of compiling and running the following code? class Test { public static void main(String arg[]) { Integer x = 1000. System.out.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www. System.quizover.1.20. int z = 0.println(li + "#" + z).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .21. 2]#1 • [0. List<Integer> li = Arrays.util. import java.util. 2]#2 • [0. 1.asList(arr). 2]#2 • compilation fails Check the answer of this question online on QuizOver.1. 1. System.quizover.com QuizOver.com/pdf/how-arrays-aslist-method-works (189) Powered by QuizOver. 1.quizover. public class Tester { public static void main(String[] arg) { int i = 1. What is the output of the following code? Author: Pedro Kowalski What is the output of the following code? import java. 2.out. 2}.List.Arrays.com . int[] arr = {0.com: Question: how arrays aslist method works Permalink: http://www. 2]#1 • [0. 2]#2 • [0.http://www. arr[i] = z = ++i. 1. 2. } } Please choose only one answer: • [0.4. 22.com QuizOver. What is the output of the following code? Author: Pedro Kowalski What is the output of the following code? import java. int z = 0.com . 2]#1 • [0. 1.. public class Tester { public static void main(String. arr[i] = z = ++i.out.quizover.util. 2. 2]#1 • compilation fails Check the answer of this question online on QuizOver. 2]#2 • [0. 1.com/pdf/arrays-aslist-method-and-wrappers-in-java (190) Powered by QuizOver. xyz) { int i = 1. } } Please choose only one answer: • [0. List<Integer> li = Arrays.com: Question: arrays aslist method and wrappers in java Permalink: http://www..util.http://www. Integer[] arr = {0.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . 2]#2 • [0.4.1. 2.Arrays.asList(arr). import java.println(li + "#" + z). 1.List. 2}.quizover. System. } } Please choose only one answer: • Compilation Fails due to possible loss of precision • 20 Check the answer of this question online on QuizOver. b+=10.23.http://www.println(b). What is the result of compiling and running the following program? Author: Nikhil Kumar What is the result of compiling and running the following program? class ExamDemo2{ public static void main(String [] args){ byte b=10.com: Question: use of compound assignment operator in java nikhil kumar Permalink: http://www. System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.com .com QuizOver.out.1.4.com/pdf/use-of-compound-assignment-operator-in-java-nikhil-kumar (191) Powered by QuizOver.quizover. .com: Question: operators in java clelson Permalink: http://www. } } Please choose only one answer: • 1 • 2 • 3 • 4 • 5 • 6 Check the answer of this question online on QuizOver.com/pdf/operators-in-java-clelson (192) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1.4.24.http://www.com .com QuizOver.quizover.println(true?false?"7":false?"6":false?true?"5": true?"4":"3":"2":"1"). parans) { System. What is the result of compiling and running the following code? Author: Anonymous User What is the result of compiling and running the following code? public class Test { public static void main(String.out.quizover.. 1f. 1]) {} • if (f1 == f2[1]) {} Check the answer of this question online on QuizOver.quizover. Author: AlinaIoana Florea Taking in consideration the following declarations.. 3.com .==". signs Permalink: http://www.1f.1f. float[][] f2 = { {1.2f.com/pdf/java-arrays-quotquot-signs (193) Powered by QuizOver.1. which lines wil.4. float[] f1 = { 2. {2.http://www.. {3.0f }.com QuizOver. 3.25. which lines will compile? float f = 1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Please choose all the answers that apply: • if (f == f2) {} • if (f == f2[0][0]) {} • if (b= f2[1][0]) {} • if (f == f2[2.0f}.com: Question: java arrays[] + ".2f}.quizover.3f} }. Taking in consideration the following declarations. Long b= 2L. 1. 4. (SCJP6) What is printed from: Author: AlinaIoana Florea (SCJP6) What is printed from: byte b=10.http://www.com: Question: ternary/conditional operator SCJP6 What AlinaIoana Florea Oracle Permalink: http://www.com . b += (b<127)? b>-128? b+=10 :0 :"5" .quizover. System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.quizover.com/pdf/question-ternary-conditional-operator-scjp6-what-alinaioana-florea-ora (194) Powered by QuizOver.1.26.println(b). Please choose only one answer: • 20 • 30 • Compilation fails because "b > -128" is not surrounded by parenthesis • Compilation fails because a String("5") can not be assigned to a "byte" • An exception is thrown at runtime Check the answer of this question online on QuizOver.com QuizOver. quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www. Chapter: Variables and Methods 1.com .4. Variables and Methods Questions (195) Powered by QuizOver. 1.out.http://www. } System.com: Question: Using java variable before initialization Permalink: http://www. } Please choose only one answer: • 7 • 8 • 9 • a compilation error Check the answer of this question online on QuizOver.4.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . y. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public static void main(String[] args) { int x = 5.quizover. while (++x < 7) { y = 2.com/pdf/using-java-variable-before-initialization (196) Powered by QuizOver.com .1.println(x + y). com QuizOver. a NoSuchMethodError exception would be thrown • There is a compilation error at declaring the main() argument.com/pdf/how-to-write-method-main-in-java (197) Powered by QuizOver.http://www.println("JavaChamp").4. should be an array of String instead Check the answer of this question online on QuizOver.out.com .2.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1.com: Question: How to write method main in java? Permalink: http://www.quizover.quizover. Would the following code compile and run? Author: JavaChamp Team Would the following code compile and run? public class Tester { public static void main(String args) { System. } } Please choose only one answer: • The program will compile and run fine printing JavaChamp as output • The program will compile fine but won't run correctly. com: Question: java class data members Permalink: http://www.1. } static int x. x is not initialized Check the answer of this question online on QuizOver.out. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static { int x = 3.http://www.3. // line 7 System.quizover. } } Please choose only one answer: • 3 • 2 • -1 • Compilation error at line 7.println(x).quizover.com QuizOver.com/pdf/java-class-data-members (198) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.com . public static void main(String[] args) { x--. com/pdf/how-to-use-java-local-variables (199) Powered by QuizOver. while(++x<5) y++.com: Question: How to use java local variables? Permalink: http://www.println(y).quizover. System.quizover. } } Please choose only one answer: • 0 • 3 • 4 • Compilation error Check the answer of this question online on QuizOver. What is the result of compiling and running the following program? Author: JavaChamp Team What is the result of compiling and running the following program? public class Tester { public static void main(String[] args) { int x = 1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1.out. int y.com .4.com QuizOver.http://www.4. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.out.println(y).com/pdf/java-local-variables-initialization (200) Powered by QuizOver.http://www. } } Please choose only one answer: • 0 • 3 • 4 • Compilation error Check the answer of this question online on QuizOver.quizover. while(++x<5) y++. int y=0. What is the result of compiling and running the following program? Author: Yasser Ibrahim What is the result of compiling and running the following program? public class Tester { public static void main(String[] args) { int x = 1.com: Question: Java local variables initialization Permalink: http://www.com QuizOver.5. System.com .4.1. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover. What is the result of compiling and running the following program? Author: Yasser Ibrahim What is the result of compiling and running the following program? public class Tester { public static void print(Integer arg){ System.out.quizover.print("int"). } } Please choose only one answer: • int • Integer • RuntimeException is thrown at run time • Compilation error Check the answer of this question online on QuizOver.print("Integer").out.com QuizOver.6.com .1.4.http://www. } public void print(int arg){ System.com/pdf/how-to-call-java-static-method (201) Powered by QuizOver. } public static void main(String[] args) { print(new Integer(3)).com: Question: How to call java static method? Permalink: http://www. Check the answer of this question online on QuizOver.%javaChamp. • int $JavaChamp. • int 2009JavaChamp.javaChamp.7.quizover.com: Question: how to declare valid java variable? Permalink: http://www.http://www.quizover.4.1.com/pdf/how-to-declare-valid-java-variable (202) Powered by QuizOver. • int . • int _.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. Which of the following is a valid variable declaration? Author: JavaChamp Team Which of the following is a valid variable declaration? Please choose all the answers that apply: • int _javaChamp. 8.1.com: Question: How to write a java bean? Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.4.quizover.http://www. Which of the following methods follow the JavaBean standards? Author: JavaChamp Team Which of the following methods follow the JavaBean standards? Please choose all the answers that apply: • public void addJCListener(JCListener listener) • void setName(String name) • public void removeJCListener(MCListener listener) • public boolean isDeleted() • public void fetchName(String name) Check the answer of this question online on QuizOver.com/pdf/how-to-write-a-java-bean (203) Powered by QuizOver.com .com QuizOver. http://www.4. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { if(true){ int x = 5.quizover.com: Question: What is java local variables scope? Permalink: http://www.out.9. System.print(x).quizover.com QuizOver. } else { ++x. System.print(x).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } } } Please choose only one answer: • 5 • 56 • 6 • Compilation error Check the answer of this question online on QuizOver.com/pdf/what-is-java-local-variables-scope (204) Powered by QuizOver.out.com .1. com/pdf/how-to-pass-variables-in-java (205) Powered by QuizOver.http://www.1.print(o1. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { int x = 12.com QuizOver.com .quizover.x).out. } } Please choose only one answer: • 0 • 12 • Compilation error • NullPointerException is thrown • Another type of exception is thrown Check the answer of this question online on QuizOver.quizover. System. static void reset(Tester obj) { obj = null.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. } public static void main(String[] args) { Tester o1 = new Tester().10.com: Question: How to pass variables in java? Permalink: http://www. reset(o1). static Tester reset( Tester obj) { obj = null. System.quizover. } } Please choose only one answer: • 0 • 12 • Compilation error • NullPointerException is thrown • Another type of exception is thrown Check the answer of this question online on QuizOver.com/pdf/how-variables-are-passed-in-java (206) Powered by QuizOver. o1 = reset(o1).http://www. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { int x = 12.out.com: Question: How variables are passed in java? Permalink: http://www.11.com . } public static void main(String[] args) { Tester o1 = new Tester().1.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . return obj.print(o1.x).com QuizOver.quizover. System. // Line 12 } } Please choose only one answer: • 11 • 12 • Compilation error at line 3 • Compilation error at line 6 • Compilation error at line 12 Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . // Line 3 static void swap( Tester obj) { obj.com/pdf/how-to-use-java-final-variable (207) Powered by QuizOver.http://www.com: Question: How to use java final variable? Permalink: http://www.4.s = 11.12.1.quizover. // Line 6 } public static void main(String[] args) { final Tester obj1 = new Tester().out. swap(obj1).com QuizOver.s).print(obj1.com . What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { final short s = 12.quizover. } public static void main(String[] args) { System.out.1.com QuizOver.http://www. } } Please choose only one answer: • 000 • 012 • 010 • compilation error Check the answer of this question online on QuizOver. System.com/pdf/static-variable-in-java-kishor-shamra (208) Powered by QuizOver. } public SomeClass() { i = 1.out.quizover.com: Question: static variable in java kishor shamra Permalink: http://www.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover. What is the output for following program? Author: Kishor Shamra What is the output for following program? public class SomeClass { static int i .print(i). System. private static int increment(int i) { return ++i.print( increment(i)).print(i).13.com .out. http://www.com QuizOver.4. Wrappers and Autoboxing Questions (209) Powered by QuizOver. Chapter: Wrappers and Autoboxing 1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .quizover. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { Integer sum1 = 125.equals(sum1)).equals(sum2)).com/pdf/iinvoking-equals-on-java-primitive-type (210) Powered by QuizOver. //line 5 } } Please choose only one answer: • Compilation error at line 3 • Compilation error at line 4 • truetruefalse • truetrueture Check the answer of this question online on QuizOver.quizover. //line 3 System. //line 2 System.4. //line 4 System.print(sum1==sum2).com . //line 1 int sum2 = 125.com: Question: Iinvoking equals() on java primitive type Permalink: http://www.1.com QuizOver.out.out.print(sum2.quizover.1.out.print(sum1.http://www. com . inserted independently at // insert code here . will compile? (choose four ) public class Tester { // insert code here public static void main(String[] args) { calculate(12). i) {} • static void calculate(Integer. } } Please choose all the answers that apply: • static void calculate(Double i) {} • static void calculate(Integer i) {} • static void calculate(int i) {} • static void calculate(int...2..quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .. Which.quizover.com/pdf/varargs-vs-autoboxing-in-java (211) Powered by QuizOver.1.com: Question: var-args vs autoboxing in java Permalink: http://www..4.http://www. will compile.. inserted independently at // insert code here .com QuizOver. i) {} Check the answer of this question online on QuizOver. Author: JavaChamp Team Which. // Line 6 System.print(x+""+y). // Line 7 } } Please choose only one answer: • 1212 • Compilation error at line 5 • Compilation error at line 6 • Compilation error at line 7 • An exception is thrown at run time Check the answer of this question online on QuizOver... Given that Long and Integer extend Number.1.quizover. what is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { Number x = 12. Author: Yasser Ibrahim Given that Long and Integer extend Number.3. // Line 5 Number y = (Long) x.com QuizOver.com .http://www.4.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.com/pdf/how-does-java-autoboxing-work (212) Powered by QuizOver.com: Question: How does java autoboxing work? Permalink: http://www. what is the result of co. quizover.valueOf("999"). // Line 5 double x2 = var.longValue().4. // Line 13 Long x6 = Integer.parseInt("999").com .longValue(). // Line 15 } } Please choose all the answers that apply: • Line 3 • Line 5 • Line 7 • Line 9 • Line 11 • Line 13 • Line 15 Check the answer of this question online on QuizOver.longValue().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . // Line 7 double x3 = (double) var.http://www. What causes the compilation to fail? Author: JavaChamp Team What causes the compilation to fail? public class Tester { public static void main(String[] args) { Long var = (long) 999.com: Question: How does autoboxing work in java? Permalink: http://www. // Line 9 Double x4 = Long.1. // Line 11 Number x5 = Integer. // Line 3 long x1 = var.4.com QuizOver.parseInt("999").quizover.com/pdf/how-does-autoboxing-work-in-java (213) Powered by QuizOver. only two of them will print true Check the answer of this question online on QuizOver. System. 4 } }. Number[] arr2 = arr1[0].4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.print(x instanceof Integer).out. 2 }.com . { 3.print(arr1[0][0] == 1).quizover. System. System. } } Please choose only one answer: • All statements will compile • Only one will compile and will print true • Only two statements will compile and both will print ture • Only three statements will compile.print(arr1[1][0] > (Integer) arr2[0]).quizover.out.1..print(arr2[0] == x).out. what is true about the following.com QuizOver. what is true about the following System.com: Question: How to compare between java wrappers? Permalink: http://www.5.out.. System. int x = 1.com/pdf/how-to-compare-between-java-wrappers (214) Powered by QuizOver. Author: Yasser Ibrahim Given the following code fragment.out statements? public class Tester { public static void main(String[] args) { Integer[][] arr1 = { { 1. Given the following code fragment. }} Please choose only one answer: • true • false • compile time error • run time exception Check the answer of this question online on QuizOver.6.4.com/pdf/how-to-use-the-equality-operator-to-compare-a-primitive-to-a-primitive (215) Powered by QuizOver.http://www.com .com QuizOver.com: Question: how to use the equality operator to compare a primitive to a primitive? Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . System.quizover.out. what will be the output when attempt to compile and execute this code: Author: Pankaj Gupta what will be the output when attempt to compile and execute this code: class Test{ public static void main(String arg[]) { Number n=10.1.println(n==i).quizover. int i=10. 4..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .. } static void call(int. What is the output ? Author: Nikhil Kumar What is the output ? class BoxVar{ static void call(Integer. args){ call(10).com: Question: boxing and varargs issue in java Nikhil Kumar Permalink: http://www.com QuizOver.7.http://www....com/pdf/boxing-and-varargs-issue-in-java-nikhil-kumar (216) Powered by QuizOver. i){ System.out.com .quizover.println("hi"+i).out. } public static void main(String.1.println("hello"+i). } } Please choose only one answer: • compilation fails • 10 Check the answer of this question online on QuizOver.. i ){ System.quizover. } } Please choose only one answer: • Compilation Fails • 20 • Run Time Error Check the answer of this question online on QuizOver.8.com: Question: boxing unboxing issue using compound assignment Nikhil Kumar Permalink: http://www.quizover. System.4.out.com .com/pdf/boxing-unboxing-issue-using-compound-assignment-nikhil-kumar (217) Powered by QuizOver. b+=10.println(b). public static void main(String [] args){ b=10.1. What is the result of compiling and running the following program? Author: Nikhil Kumar What is the result of compiling and running the following program? class ExamDemo2{ static Byte b.http://www.quizover.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . com . } static void go(Double z){ System.http://www.quizover.com QuizOver. } static void go(Number z){ System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.out. } public static void main(String.println("int").println("Number"). go(i).com/pdf/java-primitive-wrappers (218) Powered by QuizOver.com: Question: java primitive wrappers Permalink: http://www. args) { Integer i = 6.out.out..4.9.println("Double"). What is the correct output? Author: MrDick What is the correct output? class Test { static void go(int z){ System.. } } Please choose only one answer: • "Number" • "Double" • "Object" • "int" Check the answer of this question online on QuizOver.out.println("Object"). } static void go(Object z){ System.1. 10. What is the output of the following sequence? Author: Cosmin Bolocan What is the output of the following sequence? public static void main(String[] args) { int i1 = 120.quizover.1.valueOf(i1).com .valueOf(i2).http://www.out.com/pdf/wrapper-comparation-what-is-the-output-of-the-following-sequence (219) Powered by QuizOver. in1 = Integer.out. Integer in2 = Integer.com QuizOver. } Please choose only one answer: • falsefalse • falsetrue • truefalse • truetrue Check the answer of this question online on QuizOver.print(in1==in2).valueOf(i1). int i2 = 180. System.print(in1==in2).com: Question: Wrapper comparation What is the output of the following sequence Permalink: http://www. System.4.quizover.valueOf(i2). in2 = Integer. Integer in1 = Integer.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.4.com . Garbage Collection Questions (220) Powered by QuizOver.quizover. Chapter: Garbage Collection 1. .com/pdf/when-java-object-is-eligible-for-garbage-collection (221) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. How many objects are eligible for garbage collection after executin. Author: JavaChamp Team How many objects are eligible for garbage collection after executing line 7? public class Tester { public static void main(String[] args) { Integer x = new Integer(3000).com: Question: When java object is eligible for garbage collection? Permalink: http://www.com .1. x = y. Integer z = new Integer(5000).quizover.1.http://www.4. y = z. z = null..quizover. Object a = x. Integer y = new Integer(4000). //line 7 } } Please choose only one answer: • 0 • 1 • 2 • 3 Check the answer of this question online on QuizOver. quizover.com: Question: What makes java object eligible for garbage collection? Permalink: http://www.4. to make object created. // insert code here } Please choose only one answer: • arr[0] = null. • arr = null. arr[0] = new Integer("3"). // Line 5 Integer x = arr[0]. • x = null.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. What can be inserted at // insert code here.2.http://www.quizover. Author: Yasser Ibrahim What can be inserted at // insert code here..1. x = new Integer(450)..com/pdf/what-makes-java-object-eligible-for-garbage-collection (222) Powered by QuizOver. to make object created at line 5 eligible for garbage collection? public static void main(String[] args) { Integer[] arr = new Integer[3]. • All of the above Check the answer of this question online on QuizOver.com . com/pdf/when-does-an-object-become-subject-to-garbage-collection-in-java (223) Powered by QuizOver.http://www.3.quizover. An object is subject to garbage collection in java : Author: JavaChamp Team An object is subject to garbage collection in java : Please choose only one answer: • when the program is at a point of execution that is out the scope of the object • when the object is set to null • when the object becomes unreachable Check the answer of this question online on QuizOver.com: Question: when does an object become subject to garbage collection in java? Permalink: http://www.4.1.com QuizOver.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com . Overriding and Overloading Questions (224) Powered by QuizOver.4.http://www.com .com QuizOver.quizover. Chapter: Overriding and Overloading 1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Author: Yasser Ibrahim What modification is necessary to produce the following output : SubType class Type { public Object getTypeName(){ return "Type".com .out. //line 16 System.quizover.1. } } class SubType extends Type { public String getTypeName(){//line 8 return "SubType". What modification is necessary to produce the following output : S..4.1.com/pdf/java-overloading-rules (225) Powered by QuizOver.getTypeName() to String Check the answer of this question online on QuizOver.http://www.getTypeName()).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: Java overloading rules Permalink: http://www. //line 17 } } Please choose only one answer: • No modification is needed • At line 8 change ´the return type from String to Object to be a correct overloading of getTypeName() • At line 16 change Type to SubType • At line 17 cast first.println(first.quizover.. } } public class Tester { public static void main(String[] args) { Type first = new SubType().com QuizOver. quizover.getNext(3).out.print(result). } } Please choose only one answer: • 33 • 34 • 44 • 43 • a compilation error Check the answer of this question online on QuizOver. result = new Base().com .com QuizOver.print(result).quizover. } public static void main(String[] args) { int result = new Derived().com/pdf/can-override-java-final-method (226) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . System.4.2.com: Question: Can override java final method? Permalink: http://www.out. System.http://www. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? class Base { public final int getNext(int i) { return ++i.1. } } public class Derived extends Base { public int getNext(int i) { return i++.getNext(3). } • Creature getIt(Creature c) {return this.com QuizOver.} Check the answer of this question online on QuizOver. inserted independently at // insere code here.com .4.com: Question: Overriding rules in java Permalink: http://www.} • private Falcon getIt() { return new Falcon(). Author: JavaChamp Team Which statement(s).com/pdf/overriding-rules-in-java (227) Powered by QuizOver. Which statement(s).. inserted independently at // insere code here..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . will compile? class Creature { Creature getIt() { return this. } } class Bird extends Creature { // insere code here } class Falcon extends Bird { } Please choose all the answers that apply: • Creature getIt() { return this.} • public Bird getIt() {return this.http://www.} • Falcon getIt() {return this.3.quizover.quizover. .1. x • Compilation error • An exception is thrown at run time Check the answer of this question online on QuizOver. val).print("int. call(val..com QuizOver.print("Long x.com: Question: var-args vs widening vs autoboxing in java Permalink: http://www.1.. Long y) { System. Long y • int.. } static void call(int. Long y").com/pdf/varargs-vs-widening-vs-autoboxing-in-java (228) Powered by QuizOver.http://www.out... } } Please choose only one answer: • Long x..com .4. x").quizover. } public static void main(String[] args) { int val = 3. x) { System. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static void call(Long x.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.out. http://www. call(val.com QuizOver.com: Question: var-args vs autoboxing vs widening in java Permalink: http://www.5.. Number y) { System. x) { System. Long y").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .. x")..com/pdf/varargs-vs-autoboxing-vs-widening-in-java (229) Powered by QuizOver. } } Please choose only one answer: • Long x.print("Long x. val).quizover. Long y • int. } static void call(Number x.out.. x • Number x. Number y").com .4. Long y) { System. } public static void main(String[] args) { int val = 3.quizover. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { static void call(Long x.1.out.print("int.out.. } static void call(int.print("Number x.. Number y • Compilation error • An exception is thrown at run time Check the answer of this question online on QuizOver. com: Question: How to override method with exceptions in java? Permalink: http://www.com .4.6..1.com QuizOver. inserted independently at //insert overridden call() here.FileNotFoundException {} • void call() throws RuntimeException {} • void call() throws IllegalArgumentException. will represent an overridden call() and compile with no error? class Base { void call() throws IllegalArgumentException { } } public class Derived extends Base { //insert overridden call() here } Please choose all the answers that apply: • public void call() throws IllegalArgumentException {} • void call() throws IllegalArgumentException. w..http://www. inserted independently at //insert overridden call() here.RuntimeException {} • private void call() {} Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Which.com/pdf/how-to-override-method-with-exceptions-in-java (230) Powered by QuizOver.quizover.quizover. Author: JavaChamp Team Which. print("Derived").com: Question: final parameters when overriding Permalink: http://www.com .then the output will be "Base" Check the answer of this question online on QuizOver.7. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? class Base { public void method(final int x) { System.out.out.1.then the output will be "Derived" • Won't compile because of line 1.print("Base"). } } public class Derived extends Base { public void method(int x) { // line 1 System.com QuizOver.com/pdf/final-parameters-when-overriding (231) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } } Please choose only one answer: • will compile fine and wil print "Derived" • will compile fine and wil print "Base" • Won't compile because of line 1. b.method(3).quizover. } public static void main(String[] args) { Base b = new Derived().Can be corrected by marking x as final.quizover.4.http://www.Can be corrected by marking x as final. 4.com: Question: valid return types in overriding in java Permalink: http://www.1. What is the o/p of the given code? Author: Abhishek Sawant What is the o/p of the given code? class Ret{ public long tryIt(){ long num = 25.com . return num.tryIt()).http://www. // $4 } } Please choose only one answer: • a) 25 • b) 50 • c) Compilation Error at $2 • d) Compilation Error at $3 • e) Runtime Exception at $4 • f) None of the above Check the answer of this question online on QuizOver.quizover. // $3 System. // $2 } public static void main(String []args){ Ret r = new ReturnType().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . return ch.com/pdf/valid-return-types-in-overriding-in-java (232) Powered by QuizOver.println(r.out. long num = 50. // $1 } } class ReturnType extends Ret{ public long tryIt(){ char ch = 'a'.quizover.8.com QuizOver. Which method executes.com: Question: legal overriding in java Permalink: http://www.y)).1.9. Author: Abhishek Sawant o/p of this program is 35.4. overriding • e) #3 . short x =15.println(d.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } } public class DerivedI extends BaseI{ public int doSum(int a. whether it is m.. o/p of this program is 35.out. .doSum(x. short b){ // #1 return(a+b). } public static void main(String []args){ DerivedI d = new DerivedI().quizover. . whether it is method Overloading or method Overriding? class BaseI{ public int doSum(short a. } public int doSum(short a. superclass method. overloading • f) None of the above Check the answer of this question online on QuizOver..com . short b){ // #3 return(a+b). System.short b){ // #2 return(a+b).com/pdf/legal-overriding-in-java (233) Powered by QuizOver.quizover. Which method executes. No overloading or overriding • b) #2 . } } Please choose only one answer: • a) #1 .com QuizOver. short y =20. overriding • c) #2 . overloading • d) #3 .http://www. 4f).com QuizOver.} } Please choose only one answer: • The program displays "superclass" followed by "9.0" as an output.com: Question: Java overriding (the flow of control) Permalink: http://www.disp(). Check the answer of this question online on QuizOver.10.out.println("superclass").ceil(8.println(i).1.} } class MySub extends MySuper { double i=Math.0" as an output. • The program displays "superclass" followed by "superclass" as an output.out. obj.com/pdf/java-overriding-the-flow-of-control (234) Powered by QuizOver. public static void main(String arg[]) { MySuper obj= new MySub().quizover. • The program displays "9.} void disp(){System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What will be the output : Author: Pankaj Gupta What will be the output : class MySuper { MySuper(){disp().0" followed by "9.0" followed by "9.http://www.0" as an output. } void disp(){System. • The program displays "0.com .quizover.4. What is the result of compiling and running this program ?If compil. args){ new Dont()..quizover.. } public void showItem(){ } } abstract class A extends Test { A(){ System.out.1.println("Hi everyOne"). } abstract public void showItem().11.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/overriding-in-java-nikhil-kumar (235) Powered by QuizOver.com . } } Please choose only one answer: • Compile time error • an exception may be thrown • Hello Hi everyOne Check the answer of this question online on QuizOver.println("Hello").. Author: Nikhil Kumar What is the result of compiling and running this program ?If compiles successfully assume "java Dont" at command line class Test { Test(){ System.out.4.com QuizOver.quizover.com: Question: overriding in java nikhil kumar Permalink: http://www. } class Dont extends A { public void showItem(){ } public static void main(String..http://www. com: Question: java method overloading Permalink: http://www. } } Please choose only one answer: • Compilation fails. • 0 • 1 • 2 • -1 Check the answer of this question online on QuizOver. super. Given the code.book().12.com/pdf/java-method-overloading (236) Powered by QuizOver. What is the result? Author: Robin Singh Given the code.http://www.4. hotel.out. System. bookings += size.bookings). } } public class SuperHotel extends Hotel { public void book() { bookings--. } public static void main(String args[]) { Hotel hotel = new SuperHotel(). public void book() { bookings++.quizover.print(hotel.com QuizOver. What is the result? class Hotel { public int bookings. } public void book(int size) { book().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1.quizover.book(2).com . • An exception is thrown at runtime. com QuizOver.com .quizover.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. Chapter: Collections 1. Collections Questions (237) Powered by QuizOver. 1.println(nvMap). } } Please choose only one answer: • {aa=1.put("gg". What is the output of compiling and running the following program? Author: JavaChamp Team What is the output of compiling and running the following program? import java. 1). ee=3. nvMap. NavigableMap nvMap = tree.quizover. tree. public class Tester { public static void main(String[] args) { TreeMap tree = new TreeMap().com .com/pdf/how-to-use-java-headmap (238) Powered by QuizOver.util. tree.com QuizOver. cc=2. 4).http://www.4.TreeMap. 5).NavigableMap.util.put("nn". 3).put("cc". false).out. tree. 2).com: Question: How to use java headMap? Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . import java. // line 16 System.put("aa". nn=5} • Compilation error at line 16 • Exception is thrown at line 16 Check the answer of this question online on QuizOver. tree. cc=2. ee=3} • {aa=1.1.put("ee".quizover.headMap("ee". 1).com/pdf/what-does-java-headmap-do (239) Powered by QuizOver.ee=3} • {aa=1.2. cc=2.1.put("gg". System. false).util. NavigableMap nvMap = tree. tree. 4).TreeMap.headMap("ee".4.http://www.com .put("aa". 2). tree. cc=2} • {aa=1. gg=4} • No output is produced • Compilation error Check the answer of this question online on QuizOver.util. ee=3.com QuizOver.NavigableMap. cc=2. tree. } } Please choose only one answer: • {aa=1.quizover.print(nvMap). 3).put("cc".com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . public class Tester{ public static void main(String[] args) { TreeMap tree = new TreeMap().com: Question: What does java headMap() do? Permalink: http://www.put("ee". import java. tree. What is the output of compiling and running the following program? Author: JavaChamp Team What is the output of compiling and running the following program? import java.out.quizover. 7.print(value).http://www.TreeSet. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java.4.Arrays.Set.out.3. } } } Please choose only one answer: • Compilation error • 75734 • 3457 • 34577 Check the answer of this question online on QuizOver.1. set.com: Question: how to sort java Treeset? Permalink: http://www. public class Tester extends Thread { public static void main(String[] args) { Integer[] arr = {7.5. for(Integer value: set){ System. Set<Integer> set = new TreeSet<Integer>(Arrays.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com . import java. import java.util.util.util.com QuizOver.3}.add(4).quizover.asList(arr)).com/pdf/how-to-sort-java-treeset (240) Powered by QuizOver.quizover. myFooSet. } public boolean equals(Object f) { return true. } public boolean equals(Foo f) { return false.com/pdf/how-to-override-equals-in-java (241) Powered by QuizOver.. myFooSet.4. System.Set. myFooSet.add(new Foo(2)).quizover.quizover. } } class Foo { Integer code.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Foo(Integer c) { code = c.add(new Foo(3)).http://www..out.com: Question: how to override equals() in java? Permalink: http://www. import java. } } Please choose only one answer: • 1 • 3 • 5 • compilation error Check the answer of this question online on QuizOver.size()). myFooSet. What is the expected output after compiling and running the followi.HashSet.util. public class Test{ public static void main(String[] args) { Set<Foo> myFooSet = new HashSet<Foo>(). myFooSet.add(new Foo(1)).util. Author: Yasser Ibrahim What is the expected output after compiling and running the following code? import java.1.com .add(new Foo(3)).4.add(new Foo(2)). } public int hashCode() { return 17.print(myFooSet. com QuizOver.(242) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.quizover.com . What is the output of compiling and running the following code? Author: Yasser Ibrahim What is the output of compiling and running the following code? public class Test{ public static void main(String[] args) { Foo foo1 = new Foo(1).out. } } class Foo { Integer code.com/pdf/overriding-equals-method-in-java (243) Powered by QuizOver.com: Question: overriding equals() method in java Permalink: http://www. } public boolean equals(Foo f) { return false.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.4.equals(foo2)).print(foo1. } } Please choose only one answer: • true • false Check the answer of this question online on QuizOver.1. System.quizover. } public boolean equals(Object f) { return true.com QuizOver.5.quizover. Foo(Integer c) { code = c. Foo foo2 = new Foo(2).com . The following code will throw a runtime exception.com .com QuizOver.quizover.add("A").add(new Foo()). which line cause.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . which line causes the exception? import java.4. import java.util.add("A")..quizover.. // Line 2 Set t = new TreeSet().com/pdf/inserting-into-a-treeset-in-java (244) Powered by QuizOver. public class Test{ public static void main(String[] args) { Set s = new HashSet().util. s.util. // Line 1 s.com: Question: inserting into a TreeSet in java Permalink: http://www.HashSet. // Line 4 } } class Foo {} Please choose only one answer: • Line 1 • Line 2 • Line 3 • Line 4 Check the answer of this question online on QuizOver. Author: Yasser Ibrahim The following code will throw a runtime exception. import java.6. t.1.TreeSet.add(new Foo()). // Line 3 t.http://www.Set. com . } } Please choose only one answer: • 10 • 1-1 • un expected result • 20 • 2-1 • compilation error Check the answer of this question online on QuizOver. System.4.out.com: Question: using binarySearch with an array in java Permalink: http://www.print(Arrays. System.print(Arrays. "You")).com/pdf/using-binarysearch-with-an-array-in-java (245) Powered by QuizOver.util.out. "champion")). Arrays. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? import java.Arrays. "champion" }. public class Tester{ public static void main(String[] args) { String[] arr = { "java".quizover.quizover.7.sort(arr).http://www.binarySearch(arr. "champ".binarySearch(arr.1.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . print(Arrays.Arrays.quizover.binarySearch(arr. "champ".http://www. "You")). System. "you" }. "java")). System.4. public class Tester { public static void main(String[] args) { String[] arr = { "java".1.com: Question: searching an array using binarySearch in java Permalink: http://www.print(Arrays.out. } } Please choose only one answer: • 02 • 0-1 • 13 • the result is unpredictable • compilation error Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .binarySearch(arr.quizover.com QuizOver.out.8. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java.com/pdf/searching-an-array-using-binarysearch-in-java (246) Powered by QuizOver.util. public class Tester { public static void main(String[] args) { Integer[] arr = { 1.binarySearch(arr.com/pdf/binarysearch-in-java (247) Powered by QuizOver.9.com .util.1.quizover. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? import java.out.print(Arrays.Arrays.com QuizOver.4.com: Question: binarySearch in java Permalink: http://www. System. // line 1 System. 3 }.quizover.print(Arrays. 1)).out.http://www. // line 2 } } Please choose all the answers that apply: • line 1 will print 0 • line 1 will print 1 • line 1 causes compilation error • line 2 will print 0 • line 2 will causes compilation error • line 2 will causes RunTimeException Check the answer of this question online on QuizOver.binarySearch(arr.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . 2. "javachamp")). print(humans.quizover.com QuizOver.add(new Human(33)).util.print(humans.List.Collections. } public int compareTo(Human h) { return h.age.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .util.com . System. humans.add(new Human(21)).ArrayList.quizover. public Human(int age) { this. Collections.util.age = age. import java.com/pdf/how-to-implement-comparable-in-java (248) Powered by QuizOver.age).out. public class Test{ public static void main(String[] args) { List<Human> humans = new ArrayList<Human>(). humans.sort(humans).size()).get(0).com: Question: How to implement Comparable in java Permalink: http://www.compareTo(this.add(new Human(21)). } } class Human implements Comparable<Human> { int age.http://www. } } Please choose only one answer: • 333 • 334 • 133 • 134 • Compilation fails Check the answer of this question online on QuizOver. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? import java.10. import java.1.add(new Human(13)). humans. System. humans.4.out.age). age).11.compareTo(this. c).add(new Human(33)).age).quizover.List.sort(humans).age). humans.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Human h2) { return h1. (249) Powered by QuizOver. public Human(int age) { this.add(new Human(21)).util.4.com .age = age.util. humans. } } Please choose only one answer: • line 1 causes a compilation error (no duplicates are allowed) • line 2 causes a compilation error.age. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java.com QuizOver.compareTo(h2. Collections.sort(humans. import java.print(humans.Comparator.add(new Human(13)). } } class HumanComparator implements Comparator<Human> { public int compare(Human h1. humans. the correct instantiation for HumanComparator is as so : new HumanComparator<Human>() • line 4 causes a compilation error.Collections.age.out.print(humans.util. import java. // line 2 Collections. must supply a Comparator to methos sort.util.ArrayList. public class Tester{ public static void main(String[] args) { List<Human> humans = new ArrayList<Human>().add(new Human(21)). } public int compareTo(Human h) { return h. humans.1.get(0).get(0).age). import java.out. // line 3 System. } } class Human implements Comparable<Human> { Integer age. // line 4 System. // line 1 HumanComparator c = new HumanComparator().http://www. com QuizOver.http://www.com/pdf/how-to-sort-a-collection-in-java (250) Powered by QuizOver.com: Question: how to sort a collection in java? Permalink: http://www.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .• • The program compiles and runs fine printing 1333 The program compiles and runs fine printing 3313 Check the answer of this question online on QuizOver.com .quizover. 21. public class Test{ public static void main(String[] args) { Set<Human> humans = new HashSet<Human>().Set. humans. } public String toString() { return ""+this.age = age. humans.com QuizOver. import java.age.print(humans.add(new Human(21)). 21] • 3 [21.util. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? import java. 33.com .age.quizover.add(new Human(33)).print(humans). System. 13.compareTo(this. 13] • compilation error • exception is thrown at run time Check the answer of this question online on QuizOver. System.4.http://www.size()+" ").add(new Human(13)).quizover.1.util.com: Question: inserting into a HashSet in java Permalink: http://www. } public int compareTo(Human h) { return h. humans.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.add(new Human(21)).com/pdf/inserting-into-a-hashset-in-java (251) Powered by QuizOver. } } Please choose only one answer: • 4 [33.age). public Human(int age) { this.12. humans.HashSet.out. } } class Human implements Comparable<Human> { Integer age. humans.quizover. the set humans allows for objects of type Human wi.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .util. } } Please choose only one answer: • only override method equals() in Human as follows: • public boolean equals(Object h) { return this.com QuizOver. humans.http://www.util.add(new Human(21)). the set humans allows for objects of type Human with the same age to be inserted.age==((Human)h).Set. public Human(int age) { this.1. } must override both methods hashCode() and equals() as illustrated in the above answers Check the answer of this question online on QuizOver. } } class Human { Integer age. public class Test{ public static void main(String[] args) { Set<Human> humans = new HashSet<Human>(). Author: Yasser Ibrahim In this program.add(new Human(13)).. } only override method hashCode() in Human as follows: • public int hashCode(){ return 17.4.add(new Human(21)).com: Question: How the Set collection allows no duplicates in java ? Permalink: http://www. What can be done to make the set reject any Human object with value age equals to age value for an already inserted human object? import java.age = age.. import java.HashSet. In this program.add(new Human(33)).13. humans.com/pdf/how-the-set-collection-allows-no-duplicates-in-java (252) Powered by QuizOver.com .age.quizover. humans. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.http://www.(253) Powered by QuizOver.com .quizover. put(2.com . map.ceilingKey(2)). map. System. public class Test { public static void main(String[] args) { TreeMap<Integer.floorKey(1)). System.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .lowerKey(1)). System. "one").out.print(map. "four"). System.com/pdf/treemap-methods-in-java (254) Powered by QuizOver.1.out.put(3.String> map = new TreeMap<Integer.util. } } Please choose only one answer: • 3211 • 321null • 321-1 • 231null • 2310 Check the answer of this question online on QuizOver.14.higherKey(2)). What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java.put(1.quizover.quizover.com QuizOver.String>().com: Question: TreeMap methods in java Permalink: http://www. "two"). map.print(map.4.TreeMap.print(map.http://www.out.put(4. "three"). map.print(map. • Returns the least key strictly greater than the given key.com . or null if there is no such key.com QuizOver.quizover.com/pdf/ceilingkey-in-treemap-in-java (255) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.com: Question: ceilingKey in TreeMap in java Permalink: http://www. What does the method ceilingKey in TreeMap do? Author: Yasser Ibrahim What does the method ceilingKey in TreeMap do? Please choose only one answer: • Returns the least key greater than or equal to the given key.15. or null if there is no such key. • Returns the least key in the tree Check the answer of this question online on QuizOver.http://www.quizover.1. headMap and subMap in java Permalink: http://www. public class Test { public static void main(String[] args) { TreeMap<Integer. "three").http://www.1. 3).put(2.tailMap(2). map. map.com QuizOver. "four"). 4=four} • {2=two.com . 3=three} • {2=two} • no output is printed Check the answer of this question online on QuizOver. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java.headMap(4). map. SortedMap<Integer.com/pdf/tailmap-headmap-and-submap-in-java (256) Powered by QuizOver. SortedMap<Integer. "two"). String> smap2 = smap1.com: Question: tailMap.String> map = new TreeMap<Integer. 3=three.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .put(1.16.4. "one"). SortedMap<Integer.String>().TreeMap.util. import java.quizover.println(smap3). } } Please choose only one answer: • {2=two.put(4. String> smap1 = map.quizover.util.SortedMap.subMap(2.out. map. System. String> smap3 = smap2.put(3. add(2). map. public class Test { public static void main(String[] args) { TreeSet<Integer> map = new TreeSet<Integer>(). map.add(9).println(smap).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .add(7). 4. 5.TreeSet. 9] • [2.quizover.add(1). 7.com/pdf/subset-in-java (257) Powered by QuizOver. } } Please choose only one answer: • [2.SortedSet. 5] • [2.com . 4] Check the answer of this question online on QuizOver. 7] • [2. map.com: Question: subSet in java Permalink: http://www. 4.subSet(2. 7] • [2. 4.4. 5. 4.add(4).util.7).1. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java.com QuizOver.17. map.util. import java.out. SortedSet<Integer> smap = map.add(5). map.http://www. map.quizover. System. add(0). queue.peek().quizover.remove(). 4.poll(). 7.add(0).add(3).peek(). • queue.add(7).4. } } Please choose all the answers that apply: • queue.peek().quizover.poll()..queue. queue.queue.util.queue.println(queue).out. • queue. independently.http://www.remove(). What can be inserted.1. at line // insert code here to cause the program to print out : [3.offer(0)..queue.18. independently. Author: Yasser Ibrahim What can be inserted. 0] import java.*. // insert code here System. queue.add(1). • queue.queue. at line // insert code here to.add(0). queue.com/pdf/priorityqueue-methods-in-java (258) Powered by QuizOver.com: Question: PriorityQueue methods in java Permalink: http://www.add(4).peek().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .poll().queue. public class Test { public static void main(String[] args) { Queue<Integer> queue = new LinkedList<Integer>(). Check the answer of this question online on QuizOver.queue.queue.com QuizOver.queue.com . What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? import java.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .19. i < s.quizover.9 99.9 99. public class Test { public static void main(String[] args) { TreeSet s = new TreeSet().pollFirst()+" ").9 • 1 96.9).util. } } } Please choose only one answer: • 1 96.print(s.1. i++) { System.add(99.com . s.size().quizover.4.add(1).add(96.com: Question: inserting into a non generic TreeSet in java Permalink: http://www.add(99.http://www.9 99.com/pdf/inserting-into-a-non-generic-treeset-in-java (259) Powered by QuizOver.com QuizOver. for (int i = 0.*. s.9 • 1 • compilation error • an exception is thrown at run time Check the answer of this question online on QuizOver.9).out.9). s. s. quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . then hashCode(o1)== hashCode(o2) must return true • if o1. then hashCode(o1)== hashCode(o2) might return true • if o1.com .equals(o2) is false.1.equals(o2) must return true Check the answer of this question online on QuizOver.4. which of the following is true? Please choose all the answers that apply: • if o1.com: Question: equals and hashCode contract in java Permalink: http://www.20. which of the fol. then hashCode(o1)== hashCode(o2) must return false • if o1.quizover. then hashCode(o1)== hashCode(o2) might return true • if hashCode(o1)== hashCode(o2) returns true then o1.. Author: JavaChamp Team Based on equals() and hashCode() contract in java.com/pdf/equals-and-hashcode-contract-in-java (260) Powered by QuizOver. Based on equals() and hashCode() contract in java.equals(o2) is true.equals(o2) is false.http://www.com QuizOver.equals(o2) is true.. } } } Please choose only one answer: • JavaChamp. the correct method is toList not asList • compilation error at line 2. // line 1 arr[2] = ".asList(arr). "Champ".com".util.com .com QuizOver.*. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java. // line 2 for (String word : list) { System. ".quizover. List<String> list = (List<String>) Arrays. • JavaChamp.out.21. public class Test { public static void main(String[] args) { String[] arr = { "Java".quizover.1.com/pdf/aslist-in-java (261) Powered by QuizOver.http://www.com • compilation error at line 1.4.print(word). cannot modify array after converting to a List • compilation error in other lines than lines 1 and 2 Check the answer of this question online on QuizOver.com: Question: asList in java Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved ." }. com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. Chapter: Generics 1.4.http://www. Generics Questions (262) Powered by QuizOver.quizover. //line 2 list2. What is the result of compiling and running the following program? Author: Yasser Ibrahim What is the result of compiling and running the following program? import java. can add objects of type String only • 1 Check the answer of this question online on QuizOver. cannot convert from List<String> to List<Object> • Compilation error at line 3.Type mismatch.util.//line 4 } } Please choose only one answer: • Compilation error at line 1.quizover.com/pdf/how-to-declare-instantiate-java-generic-collection (263) Powered by QuizOver.size()).println(list2.1.//line 3 System.out.//line 1 List<Object> list2 = list1. import java.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.ArrayList.add(new Integer(12)).List.1.com .com: Question: How to declare instantiate java generic collection? Permalink: http://www.com QuizOver.util. must initialize the size • Compilation error at line 2. public class Tester { public static void main(String[] args) { List<String> list1 = new ArrayList<String>().quizover. size()).add(new Integer(9)).com: Question: How to add to java generic collection? Permalink: http://www. What is the result of compiling and running the following program u.http://www. interface chewable {} class Gum implements chewable {} public class Tester { public static void main(String[] args) { List<Gum> list1 = new ArrayList<Gum>(). System.com/pdf/how-to-add-to-java-generic-collection (264) Powered by QuizOver.com QuizOver.4. } } Please choose only one answer: • Compilation error • 2 will be printed but with warnings • 2 will be printed without warnings • An exception will be thrown at runtime Check the answer of this question online on QuizOver..com ..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . list2.util. list1.add(new Gum()).2.1.out.println(list2.quizover. import java.ArrayList.5 or higher? import java.util. List list2 = list1. Author: JavaChamp Team What is the result of compiling and running the following program using JDK 1.List.quizover. // line 5 } } Please choose only one answer: • Compilation error at line 1 • Compilation error at line 4 • Runtime exception thrown at line 1 • Runtime exception thrown at line 4 • 3 Check the answer of this question online on QuizOver.ArrayList.3.size()).4..http://www.com QuizOver.add(new Gum()).List..com: Question: How to declare java generic collection? Permalink: http://www.// line 4 System.5 or higher? import java.quizover.com/pdf/how-to-declare-java-generic-collection (265) Powered by QuizOver.// line 2 list1.out.util.add(new Integer(9)).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.// line 3 list1. What is the result of compiling and running the following program u.println(list1.add(new Meat()).// line 1 list1.com . interface chewable {} class Gum implements chewable {} class Meat implements chewable {} public class Tester { public static void main(String[] args) { List list1 = new ArrayList<chewable>(). Author: Yasser Ibrahim What is the result of compiling and running the following program using jdk 1.1.util. import java. Which of the following is a correct declaration and instantiation o. • List<Object> list = new ArrayList<String>().com/pdf/java-generic-collection-rules (266) Powered by QuizOver.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved ..com QuizOver. Check the answer of this question online on QuizOver.quizover. • List<?> list = new ArrayList<String>(). • List<? extends Object> list = new ArrayList<String>().1.http://www.com . • List list = new ArrayList<String>(). Author: JavaChamp Team Which of the following is a correct declaration and instantiation of list? Please choose all the answers that apply: • List<String> list = new ArrayList<String>().quizover. • List list = new ArrayList<?>().com: Question: java generic collection rules? Permalink: http://www.4.. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .util.com .quizover. list1.com/pdf/when-cannot-add-to-a-generic-collection (267) Powered by QuizOver. // Line 19 } } Please choose only one answer: • Line 11 • Line 13 • Line 17 • Line 19 Check the answer of this question online on QuizOver.List. at what line? import java.5. at what line? Author: Yasser Ibrahim The following code contains a compilation error.com: Question: When cannot add to a generic collection? Permalink: http://www. // Line 17 list2. // Line 13 Meat meat = new Meat().ArrayList.add(meat).http://www.4.util.com QuizOver. import java. The following code contains a compilation error.add(meat).1.quizover. interface Chewable {} class Meat implements Chewable {} public class Tester { public static void main(String[] args) { List<? extends Chewable> list1 = new ArrayList<Meat>(). // Line 11 List<Chewable> list2 = new ArrayList<Chewable>(). // Line 18 list1 = printSize(list1).com/pdf/proper-instantiation-of-java-generic-collection (268) Powered by QuizOver. // Line 16 List<Chewable> list2 = new ArrayList<Chewable>(). } public static void main(String[] args) { List<? extends Chewable> list1 = new ArrayList<Meat>().http://www. The following program contains two compilation errors. import java. // Line 22 } } Please choose all the answers that apply: • Line 10 • Line 16 • Line 17 • Line 18 • Line 20 • Line 21 • Line 22 Check the answer of this question online on QuizOver.quizover. at what lines? import java.List. // Line 17 List<Meat> list3 = new ArrayList<Meat>().4.6. interface Chewable {} class Meat implements Chewable {} public class Tester { public static List<? extends Chewable> printSize(List<? extends Chewable> list) { // Line 10 System.size()).ArrayList. return list.com .util.com QuizOver.println(list. // Line 21 list3 = printSize(list3).util.com: Question: Proper instantiation of java generic collection Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .1.out.quizover. // Line 20 list2 = printSize(list2). at what lines? Author: JavaChamp Team The following program contains two compilation errors. 4 • in JDK 1.7.http://www.com QuizOver.5 • in JDK 1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .6 Check the answer of this question online on QuizOver.4.1.quizover.com/pdf/when-were-generics-first-introduced-in-java (269) Powered by QuizOver. When were generics first introduced in Java? Author: JavaChamp Team When were generics first introduced in Java? Please choose only one answer: • in JDK 1.quizover.com: Question: When were Generics first introduced in Java? Permalink: http://www. quizover.print(myFooList..ArrayList.code). import java. } } class Foo implements Comparable<Foo> { String code.com QuizOver. public class Test{ public static void main(String[] args) { List<Foo> myFooList = new ArrayList<Foo>().Collections. import java.out. Collections.util. myFooList.com: Question: how to sort a generic collection? Permalink: http://www. } } Please choose only one answer: • A • C • D • no output is printed • compilation error • exception thrown at run time Check the answer of this question online on QuizOver.4.util.add(new Foo("D")). myFooList. Foo(String c) { code = c.com . myFooList.http://www..add(new Foo("C")).sort(myFooList). } int compareTo(Foo f) { return this.util.8. Author: Yasser Ibrahim What is the expected output of compiling and running the following code? import java.code.get(0).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the expected output of compiling and running the following .quizover. System.compareTo(f.List.add(new Foo("A")).1.code).com/pdf/how-to-sort-a-generic-collection (270) Powered by QuizOver. util.get(1).. System.4. list. public class Test{ public static void main(String[] args) { List list = new ArrayList().. Foo f = new Foo().out. list.quizover. Author: Yasser Ibrahim What is the expected output of compiling and running the following code? import java.List. } } class Foo { public String toString() { return "Foo". import java. f = list. What is the expected output of compiling and running the following .ArrayList.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com .com: Question: inserting into a non-generic collection in java Permalink: http://www.1.get(0) + "-" + f).print(list. } } Please choose only one answer: • Hello-Foo • compilation error • exception at run time Check the answer of this question online on QuizOver.http://www.com QuizOver.add("Hello").add(f).9.quizover.com/pdf/inserting-into-a-nongeneric-collection-in-java (271) Powered by QuizOver.util. inserted independently at line 1. Author: JavaChamp Team Considering that all needed imports are there.10.com: Question: generic collection as return type in java Permalink: http://www.. • return new ArrayList().4. inserted indep.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . what.com QuizOver. • return new ArrayList<A>(). • return new ArrayList<C>(). Considering that all needed imports are there.com/pdf/generic-collection-as-return-type-in-java (272) Powered by QuizOver. • return new LinkedList<B>().http://www. • return new ArrayList<? extends B>(). will compile? class A {} class B extends A{} class C extends B{} public class Test { public List<? extends B> ring(){ // line 1 } } Please choose all the answers that apply: • return new ArrayList<B>().quizover. • return new PriorityQueue<B>().. Check the answer of this question online on QuizOver. what.quizover.1. there is a compilation error at // Line 2 • No. Queue<C> q1.util.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . // line2 q2 = ring(list1).11.com/pdf/generic-methods-in-java (273) Powered by QuizOver.quizover.com QuizOver. the program is free of compilation errors • No. Will the following code compile? Author: Yasser Ibrahim Will the following code compile? import java. // line4 } } Please choose all the answers that apply: • Yes. ArrayList<C> list2 = new ArrayList<C>(). there is a compilation error at // Line 3 • No. class B { } class C extends B { } public class Test { public static <E extends B> Queue<E> ring(List<E> list) { return null. // line3 q2 = ring(list2). q1 = ring(list1).quizover.com . PriorityQueue<C> q2. } public static void main(String[] args) { List<C> list1 = new ArrayList<C>(). // line1 q1 = ring(list2).1. there is a compilation error at // Line 4 Check the answer of this question online on QuizOver.com: Question: generic methods in java Permalink: http://www.*.4.http://www. there is a compilation error at // Line 1 • No. put("Jess". • replace line 3 with int x = students. Map students = new HashMap().util. students.com QuizOver.. ids.intValue(). • replace line 2 with Map<Integer. // Line 2 students. Author: Yasser Ibrahim How can this program be modified to make use of appropriate generic types? (one modification for each line) import java. How can this program be modified to make use of appropriate generic. • replace line 1 with List<Long> ids = new ArrayList<Long>().Integer>().add(123).add(999). int x = ((Long)students. • replace line 2 with Map<String.. Check the answer of this question online on QuizOver.ids.4.put("Jimmy".quizover.http://www.get("Jimmy")).Integer> students = new HashMap<String.quizover.com/pdf/how-to-declare-a-generic-collection-in-java (274) Powered by QuizOver.1. // Line 3 } } Please choose all the answers that apply: • replace line 1 with List<Integer> ids = new ArrayList<Integer>(). public class Test { public static void main(String[] args) { List ids = new ArrayList().String>().get(0)).ids.get(1)).get("Jimmy").com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .*.com: Question: how to declare a generic collection in java? Permalink: http://www.12. // Line 1 ids.String> students = new HashMap<Integer. quizover.Number> map = new HashMap<List<Integer>.4. new Long(1)). • 5) Map<ArrayList<Integer>. } } Please choose only one answer: • 1) Map<List<Integer>.Number>().Integer> map = new HashMap<ArrayList<Integer>. • 3) Map<List<Integer>.Long>().Integer>(). Number>().13. map. Author: JavaChamp Team Given the following incomplete program.1. Number> map = new HashMap<List<Integer>.http://www. Check the answer of this question online on QuizOver.com . • 4) Map<List<Integer>.com/pdf/how-to-declare-a-generic-map-in-java (275) Powered by QuizOver. Given the following incomplete program.util..put(new ArrayList<Integer>(). map. based on the given put statements in map.Integer>().? extends Number> map = new HashMap<List<Integer>. what is considered a correct declaration and instantiation for map ? import java. • 2) Map<List<Integer>.Integer> map = new HashMap<List<Integer>.com QuizOver.. map.put(new LinkedList<Integer>(). 1).Integer>().quizover. 12).com: Question: how to declare a generic Map in java? Permalink: http://www. public class Test { public static void main(String[] args) { // insert code here map. based on the given put stat.put(new ArrayList<Integer>().*. • 6) Map<List<Integer>.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .put(new LinkedList<Integer>().Long> map = new HashMap<List<Integer>. new Integer(1)). 4. Chapter: Formatting 1.com QuizOver.quizover.http://www.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Formatting Questions (276) Powered by QuizOver. x).// stmt4 } } Please choose all the answers that apply: • Statement 1 • Statement 2 • Statement 3 • Statement 4 Check the answer of this question online on QuizOver.// stmt2 System.quizover. int y = 3.1. (float) x).printf("%f + %f \n". x.// stmt3 System.com .com: Question: writing java printf or format statement Permalink: http://www.out. // stmt1 System.http://www. x.printf("%d + %d \n".com/pdf/writing-java-printf-or-format-statement (277) Powered by QuizOver. y.4.out.out.printf("%d + %d \n".1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. Which of the following statements produces the output 3 + 8 ? Author: Yasser Ibrahim Which of the following statements produces the output 3 + 8 ? public class Tester { public static void main(String[] args) { int x = 8. System. y). y).quizover.format("%2$d + %1$d". (float) y.com QuizOver. quizover.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .2.com/pdf/java-classes-instantiated-using-factory-method (278) Powered by QuizOver. Which of the following is instantiated using a factory method ? Author: Yasser Ibrahim Which of the following is instantiated using a factory method ? Please choose all the answers that apply: • Date • Calendar • Locale • DateFormat • NumberFormat Check the answer of this question online on QuizOver.com: Question: java classes instantiated using factory method Permalink: http://www.com .4.1.com QuizOver.quizover. com QuizOver.com .http://www.4. I/O Questions (279) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Chapter: I/O 1.quizover. Check the answer of this question online on QuizOver. Which of the following statements is a correct instantiation of Pr.1.dat")).dat")).quizover.dat").com .dat")). • PrintWriter writer = new PrintWriter(new FileWriter("file.com QuizOver.. • PrintWriter writer = new PrintWriter(new BufferedWriter("file.4.quizover.com: Question: How to instantiate java PrintWriter? Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Author: Yasser Ibrahim Which of the following statements is a correct instantiation of PrintWriter? Please choose all the answers that apply: • PrintWriter writer = new PrintWriter("file.com/pdf/how-to-instantiate-java-printwriter (280) Powered by QuizOver.http://www.1.. • PrintWriter writer = new PrintWriter(new File("file. io.append("javachamp"). } } } Please choose only one answer: • Line 5 • Line 6 • Line 7 • Line 8 • Line 11 Check the answer of this question online on QuizOver.io. // line 11 } catch (IOException e) { e.io.flush().IOException. // line 6 FileWriter fr = new FileWriter(file). // line 8 br. import java.quizover. Author: Yasser Ibrahim At what line in the following program the file "data.2. br.1.createNewFile(). import java. br.// line 5 file.http://www.txt").printStackTrace().. At what line in the following program the file "data..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . import java.com QuizOver.com . public class Tester { public static void main(String[] args) { try { File file = new File("data.com: Question: How to create file in java? Permalink: http://www.io. // line 7 BufferedWriter br = new BufferedWriter(fr).txt" will be created in the file system? import java.FileWriter.quizover.BufferedWriter.close().4.com/pdf/how-to-create-file-in-java (281) Powered by QuizOver.txt" will be c.File. } catch ( // INSERT EXCEPTION TYPE e) { e. Author: Yasser Ibrahim Given the following code segment enclosed within a try/catch block.4..dat").http://www.1.createNewFile().3.com QuizOver.printStackTrace().com . what valid Exception type can be catched causing no compilation error? try { File file = new File("file.quizover..com/pdf/what-java-exceptions-thrown-by-file (282) Powered by QuizOver.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .. } Please choose all the answers that apply: • Exception • RuntimeException • Throwable • FileNotFoundException • IOException Check the answer of this question online on QuizOver. file.com: Question: What java exceptions thrown by File? Permalink: http://www. Given the following code segment enclosed within a try/catch block. txt")).com QuizOver.com/pdf/how-to-instantiate-java-bufferedwriter (283) Powered by QuizOver.http://www. Check the answer of this question online on QuizOver.com: Question: How to instantiate java BufferedWriter? Permalink: http://www..1.quizover. Which of the following is a correct instantiation for a BufferedWri.4. • BufferedWriter bw = new BufferedWriter(new FileWriter("data.quizover.com . • BufferedWriter bw = new BufferedWriter("data. • BufferedWriter bw = new BufferedWriter(new PrintWriter("data.4.txt")).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved ..txt")).txt"). Author: JavaChamp Team Which of the following is a correct instantiation for a BufferedWriter? Please choose all the answers that apply: • BufferedWriter bw = new BufferedWriter(new File("data. http://www. Chapter: Threads 1.com QuizOver.quizover.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4. Threads Questions (284) Powered by QuizOver. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .. } public static void main(String[] args) { Tester thread = new Tester().1. What is considered an impossible output of running the following pr.code = 7.1.quizover.4. } } } Please choose only one answer: • 99777 • 97777 • 77777 • 79999 • 99999 Check the answer of this question online on QuizOver. Author: JavaChamp Team What is considered an impossible output of running the following program? public class Tester extends Thread { int code = 9.start(). i < 5. for (int i = 0.print(thread..quizover.out.http://www.code). public void run() { this. thread.com/pdf/how-java-thread-start-running (285) Powered by QuizOver.com QuizOver.com: Question: How java thread start running? Permalink: http://www.com . i++) { System. What is the result of compiling and running the following program? Author: JavaChamp Team What is the result of compiling and running the following program? public class Tester { public void validate() { int i = 0.2. } } Please choose only one answer: • Compilation error because of calling wait() outside a synchronized block • Compilation error because IllegalMonitorStateException is not handled • At runtime.com QuizOver.http://www.print(i). while (++i < 3) { try { wait().1. it throws an IllegalMonitorStateException when trying to wait • 12 Check the answer of this question online on QuizOver. } } public static void main(String[] args) { new Tester().quizover.com . } catch (InterruptedException e) { e.printStackTrace().4.validate().com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } System.com: Question: When java IllegalMonitorStateException is thrown? Permalink: http://www.com/pdf/when-java-illegalmonitorstateexception-is-thrown (286) Powered by QuizOver.quizover.out. new Thread(thread). can't invoke start() twice • runrun • IllegalThreadStateException will be thrown because of the second invoke to start() • run Check the answer of this question online on QuizOver.http://www.com: Question: Can java thread invoke start more than once? Permalink: http://www.start(). } } Please choose only one answer: • Compilation error.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } public static void main(String[] args) { Tester thread = new Tester().quizover.quizover.com QuizOver.1.print("run").3.start().com .4.com/pdf/can-java-thread-invoke-start-more-than-once (287) Powered by QuizOver.out. new Thread(thread). What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester extends Thread { public void run() { System. .com: Question: When java IllegalThreadStateException is thrown? Permalink: http://www.out. } } Please choose all the answers that apply: • Compilation error • Prints "run" twice.quizover.com .1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . thread. not necessarily consecutively • InterruptedException will be thrown • IllegalThreadStateException will be thrown • Prints "run" three times Check the answer of this question online on QuizOver. thread.run().quizover.start()..http://www.4.start(). thread.println("run").4. } public static void main(String[] args) { Thread thread = new Tester().com/pdf/when-java-illegalthreadstateexception-is-thrown (288) Powered by QuizOver. What could be a part of the output of compiling and running the fol.com QuizOver. Author: JavaChamp Team What could be a part of the output of compiling and running the following code? public class Tester extends Thread { public void run() { System. Which of the following methods defined in Thread class are static? Author: JavaChamp Team Which of the following methods defined in Thread class are static? Please choose all the answers that apply: • sleep() • start() • yield() • join() • run() Check the answer of this question online on QuizOver.com/pdf/which-thread-methods-are-static (289) Powered by QuizOver.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.http://www.com .quizover.1.4.5.com: Question: which thread methods are static? Permalink: http://www. 6.com QuizOver.com/pdf/which-methods-are-defined-in-calss-object (290) Powered by QuizOver.4.1.quizover.http://www. Which methods are defined in calss Object? Author: Yasser Ibrahim Which methods are defined in calss Object? Please choose all the answers that apply: • wait() • sleep() • toString() • finalize() • notify() Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.com: Question: which methods are defined in calss object? Permalink: http://www.com . quizover.1.com/pdf/when-to-override-thread-method-run (291) Powered by QuizOver.com QuizOver. Author: Yasser Ibrahim When a class implements interface Runnable. When a class implements interface Runnable. it must provide implementation for method start(): Please choose only one answer: • False • True Check the answer of this question online on QuizOver.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .. it must provide impleme.com: Question: when to override thread method run()? Permalink: http://www.com .7..4.http://www. com/pdf/when-a-thread-can-call-wait (292) Powered by QuizOver. must owns th.8. A thread that invokes the wait() method of an object. must owns the lock of the object.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.quizover..com QuizOver.1.http://www.4. Please choose only one answer: • True • False Check the answer of this question online on QuizOver.com: Question: when a thread can call wait()? Permalink: http://www.com .. Author: JavaChamp Team A thread that invokes the wait() method of an object. quizover.http://www.9.com/pdf/how-can-a-thread-own-the-lock-of-an-object (293) Powered by QuizOver.1.quizover. How can a thread own the lock of an object? Author: Yasser Ibrahim How can a thread own the lock of an object? Please choose all the answers that apply: • When the thread executes a synchronized instance method of that object • When the thread executes a synchronized statement block in the object • When the thread calls wait() on this object Check the answer of this question online on QuizOver.com .4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: how can a thread own the lock of an object? Permalink: http://www.com QuizOver. // line 1 new Thread("myThread").quizover.http://www.1.com/pdf/how-to-instantiate-a-thread-object (294) Powered by QuizOver.4. Which of the following Thread instantiations are correct? Author: Yasser Ibrahim Which of the following Thread instantiations are correct? public static void main(String[] args) { new Thread().com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .10. // line 3 new Thread(new Runnable(){public void run(){}}). // line 2 new Thread(new Long(14)).com: Question: how to instantiate a thread object? Permalink: http://www.getInstance(). // line 4 Thread.com . // line 5 } Please choose all the answers that apply: • line 1 • line 2 • line 3 • line 4 • line 5 Check the answer of this question online on QuizOver.quizover. 4.1.Thread class • instantiation from a class which implements the java.quizover.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com/pdf/how-to-create-a-thread-object (295) Powered by QuizOver. Thread objects are created by: Author: Yasser Ibrahim Thread objects are created by: Please choose all the answers that apply: • direct instantiation from java.Thread class • instantiation a Runnable object (from a class which implements the Runnable interface) • instantiation a Runnable object (from a class which implements the Runnable interface) and passing this Runnable object to a Thread constructor.com: Question: How to create a Thread object? Permalink: http://www.lang.lang.http://www.com QuizOver. Check the answer of this question online on QuizOver.11.com . http://www.12.4. When creating a thread by implementing Runnable interface : Author: JavaChamp Team When creating a thread by implementing Runnable interface : Please choose only one answer: • you must implement the method run() • you can override run().1.com .quizover. but in case you don't you'll be restricted to the provided run() method.com: Question: Create a thread by implementing Runnable Permalink: http://www.com/pdf/create-a-thread-by-implementing-runnable (296) Powered by QuizOver.quizover. which contains no code and does nothing Check the answer of this question online on QuizOver.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . com/pdf/instatiate-a-thread-by-implementing-runnable-interface (297) Powered by QuizOver.quizover..com .4.http://www. } } Please choose only one answer: • two times • zero times • the program will not compile Check the answer of this question online on QuizOver. painter1.1. Author: Yasser Ibrahim How many times the statement "we are painting" would be printed in this program? public class Test{ public static void main(String[] args) { Painter painter1 = new Painter()..println("we are painting"). painter2. How many times the statement "we are painting" would be printed in .13.start(). } } class Painter implements Runnable { public void run() { System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: instatiate a thread by implementing Runnable interface Permalink: http://www. Painter painter2 = new Painter().out.com QuizOver.start().quizover. .http://www.out. } } class InternetRequest implements Runnable { public void run() { System..com/pdf/starting-many-threads-together-in-java (298) Powered by QuizOver. What is the possible output of compiling and running the following . Author: JavaChamp Team What is the possible output of compiling and running the following code? public class Test { public static void main(String[] args) { Thread request1 = new Thread(new InternetRequest (). request2. request1."request#2 ").14.quizover.com: Question: starting many threads together in java Permalink: http://www.start()."request#1 ").start().print(Thread.4.currentThread().quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Thread request2 = new Thread(new InternetRequest ().com . } } Please choose all the answers that apply: • request#2 request#1 • request#1 request#2 • an InterruptedException is thrown • request#1 request#1 Check the answer of this question online on QuizOver.1.com QuizOver.getName()). t. } } Please choose only one answer: • Compilation error • compiles fine.quizover.1. } public static void main(String[] args) { Runnable c = new Writer().out.4.println("Writer run").com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.com/pdf/instatiate-a-thread-by-implementing-runnable-in-java (299) Powered by QuizOver.15.quizover.run(). but no output produced • compiles fine and prints "Writer run" • compiles fine but throws an exception Check the answer of this question online on QuizOver.com QuizOver.com . What is the output of compiling and running the following code? Author: JavaChamp Team What is the output of compiling and running the following code? class Writer extends Thread { public void run() { System. Thread t = new Thread(c).com: Question: instatiate a thread by implementing Runnable in java Permalink: http://www. 4.quizover. } public void run() { count = count + 5.com/pdf/handling-a-checked-exception (300) Powered by QuizOver.start(). t.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. System. } public void increment(int count) { ++count.println(count).increment(count). public static void main(String argv[]) { Test t = new Test ().1. t.quizover. Thread.http://www. } } Please choose only one answer: • 5 • 6 • Compilation error Check the answer of this question online on QuizOver.com: Question: handling a checked exception Permalink: http://www. What is the output of compiling and running the following code? Author: JavaChamp Team What is the output of compiling and running the following code? public class Test extends Thread { static int count = 0.com QuizOver.sleep(1000).16. Author: Yasser Ibrahim What is the could be the output of compiling and running the following code? public class Test extends Thread { static int count = 0.println(count). Thread.1.start().com .out.com: Question: running a thread in java Permalink: http://www..17. public static void main(String argv[]) throws InterruptedException { Test t = new Test ().increment(count)..sleep(1000). t.com QuizOver.com/pdf/running-a-thread-in-java (301) Powered by QuizOver.quizover. System.quizover.4. } public void increment(int count) { ++count. What is the could be the output of compiling and running the follow. t.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www. } } Please choose all the answers that apply: • 5 • 6 • Compilation error • An InterruptedException may be thrown Check the answer of this question online on QuizOver. } public void run() { count = count + 5. start().name = name..com .18. System. } } public class Test { public static void swim(String name) { System. Swimmer(String name){ this.quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www. What is the possible output of running this program once as it is a. a possible output is TomHanksHanksTom • by synchronizing swim(). Author: Yasser Ibrahim What is the possible output of running this program once as it is and once by marking swim() synchronized? class Swimmer implements Runnable{ String name .start(). } } Please choose all the answers that apply: • as it is.out.print(name)..swim(name).com/pdf/synchronized-static-method-and-threads-in-java (302) Powered by QuizOver. a possible output is TomHanksTomHanks • as it is.print(name).4. a possible output is TomHanksHanksTom • by synchronizing swim().quizover. } public void run() { Test. } public static void main(String[] args) { new Thread(new Swimmer("Tom")).com: Question: synchronized static method and threads in java Permalink: http://www.com QuizOver. a possible output is TomHanksTomHanks Check the answer of this question online on QuizOver. a possible output is HanksHanksTomTom • by synchronizing swim().out.1. new Thread(new Swimmer("Hanks")). Swimmer(String name){ this. System. It is in any order of two Tom and two Hanks Check the answer of this question online on QuizOver.start().19.quizover. the output is undetermined.quizover.4. It is in any order of two Tom and two Hanks • by synchronizing swim().1.. the output is always consecutive two Tom then two Hanks or consecutive two Hanks then two Tom • by synchronizing swim().com/pdf/synchronized-method-and-threads-in-java (303) Powered by QuizOver. Author: Yasser Ibrahim What are the possible outputs of running this program once as it is.out.name = name.out.http://www. } } public class Test { public void swim(String name) { System.com QuizOver. What are the possible outputs of running this program once as it is.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: synchronized method and threads in java Permalink: http://www. the output is undetermined.swim(name).. } public static void main(String[] args) { new Thread(new Swimmer("Tom")). } public void run() { new Test().print(name). and second with marking swim() synchronized? class Swimmer implements Runnable{ String name . new Thread(new Swimmer("Hanks")).start().print(name). } } Please choose all the answers that apply: • as it is.com . the output is always consecutive two Tom then two Hanks or consecutive two Hanks then two Tom • as it is. com QuizOver.com/pdf/synchronized-method-in-java (304) Powered by QuizOver. the output could be TomHanksHanksTom Check the answer of this question online on QuizOver.start().start(). Pool pool.print(name).swimIn(name). Author: JavaChamp Team What are the possible outputs of running this program once as it is. the output could be TomHanksTomHanks • by synchronizing swimIn(). new Thread(new Swimmer("Hanks". } } public class Pool { public void swimIn(String name) { System. this.http://www. pool)).quizover.out.quizover. pool)).pool = pool. } public void run() { pool.com: Question: synchronized method in java Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . System. Pool pool) { this. new Thread(new Swimmer("Tom". the output is always two consecutive "Tom" followed by two consecutive "Hanks" or viceversa • by synchronizing swimIn(). the output could be TomHanksTomHanks • by synchronizing swimIn().print(name). What are the possible outputs of running this program once as it is.20.1. and second with marking swimIn() synchronized? class Swimmer implements Runnable { String name. Swimmer(String name. the output is always two consecutive "Tom" followed by two consecutive "Hanks" or viceversa • as it is. } public static void main(String[] args) { Pool pool = new Pool().name = name..4..com .out. } } Please choose all the answers that apply: • as it is. com QuizOver.quizover.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.(305) Powered by QuizOver. swimIn(name).. pool)). } } Please choose only one answer: • TomTomHanksHanks • HanksHanksTomTom • HanksTomHanksTom • undetermined order • compilation error Check the answer of this question online on QuizOver. Pool pool. System.out.1.start().pool = pool. What is the possible result of compiling and running the following . Swimmer(String name.name = name.print(name). } } public class Pool { public void swimIn(String name) { synchronized { System.start().out.21. new Thread(new Swimmer("Tom".quizover. this.com . Pool pool) { this.http://www.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .print(name).. Author: Yasser Ibrahim What is the possible result of compiling and running the following code? class Swimmer implements Runnable { String name. } public void run() { pool.com: Question: how to synchronize a method in java Permalink: http://www.quizover. pool)). } } public static void main(String[] args) { Pool pool = new Pool().com/pdf/how-to-synchronize-a-method-in-java (306) Powered by QuizOver.4. new Thread(new Swimmer("Hanks". http://www. } public void run() { press(id). Author: JavaChamp Team What is the possible result of compiling and running the following code? public class Test implements Runnable { Integer id.intValue()).quizover.quizover.22. public static void main(String[] args) { new Thread(new Test()).com QuizOver.out.com .start().4. What is the possible result of compiling and running the following . } } Please choose only one answer: • 0101 • 0011 • -10-10 • -1-100 • compilation error • an exception is thrown at run time Check the answer of this question online on QuizOver.com/pdf/thread-and-synchronized-method-in-java (307) Powered by QuizOver.1.intValue()).com: Question: thread and synchronized method in java Permalink: http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .print((++id).print(id...out. } synchronized void press(Integer id) { System.start(). new Thread(new Test()). System. print((++id).23.quizover.intValue()).com .start().out. } synchronized void press(Integer id) { System.4.start().intValue())..quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the possible result of compiling and running the following . new Thread(new Test())..1.com: Question: synchronized non static method in java Permalink: http://www.com/pdf/synchronized-non-static-method-in-java (308) Powered by QuizOver. public static void main(String[] args) { new Thread(new Test()).com QuizOver. } public void run() { press(id).http://www. System.print(id. Author: Yasser Ibrahim What is the possible result of compiling and running the following code? public class Test implements Runnable { Integer id = 0. } } Please choose only one answer: • 1010 • 0101 • 0123 • compilation error • an exception is thrown at run time Check the answer of this question online on QuizOver.out. 1.http://www.com .join().24.print("main"). System. } } Please choose only one answer: • the output could be "mainrun" • the output could be "runmain" • the output could be "run" then an exception is thrown at run time • compilation error Check the answer of this question online on QuizOver. What is ture? Author: JavaChamp Team What is ture? public class Test implements Runnable { public static void main(String[] args) throws InterruptedException { Test test = new Test().out.print("run"). } public void run() { System.4.com QuizOver.com: Question: thread join java Permalink: http://www.quizover. t.out.com/pdf/thread-join-java (309) Powered by QuizOver. t.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover. Thread t= new Thread(test).start(). System.1.quizover.out. thread. thread.com .print("run"). Thread thread = new Thread(test).join().http://www.quizover.print("main").com/pdf/join-thread-in-java (310) Powered by QuizOver. } } Please choose only one answer: • the program could prints runmain • the program could prints mainrun • the compilation fails • an exception is thrown at run time Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.com QuizOver.com: Question: join thread in java Permalink: http://www.out.25. What is true? Author: JavaChamp Team What is true? public class Test implements Runnable { public static void main(String[] args) { Test test = new Test(). } public void run() { System.start(). cannot invoke start() directly on thread2 Check the answer of this question online on QuizOver. Thread thread2 = new Thread(new Test(2)).quizover.26. Author: Yasser Ibrahim What are the possible results of compiling and running the following code? public class Test implements Runnable { int id.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } } Please choose all the answers that apply: • 12main • 21main • 2main1 • 1main2 • compilation error.out. System.print(id).com ...com/pdf/run-vs-start-in-threads-in-java (311) Powered by QuizOver.1.run(). cannot invoke run() directly on thread1 • compilation error.http://www. What are the possible results of compiling and running the followin.print("main"). Test(int id) { this.quizover. thread1. } public static void main(String[] args) throws InterruptedException { Thread thread1 = new Thread(new Test(1)).com QuizOver. thread2.out.4.id = id. } public void run() { System.start().com: Question: run vs start in threads in java Permalink: http://www. quizover.27.1. to sleep (temporarily cease execution) for the specified number of milliseconds • causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds • causes the main() thread to sleep for the specified number of milliseconds • causes the currently executing thread to wait(temporarily cease execution) for the specified number of milliseconds then brings it back to run. What does sleep(long millis) in Thread class do? Author: JavaChamp Team What does sleep(long millis) in Thread class do? Please choose only one answer: • causes the thread.com/pdf/sleep-in-thread-in-java (312) Powered by QuizOver.com .quizover.com: Question: sleep in thread in java Permalink: http://www. Check the answer of this question online on QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www. which sleep is invoked on.4.com QuizOver. http://www..start().id = id. System.print(id). } } Please choose all the answers that apply: • main22 • 0main2 • main02 • 2main2 • compilation error for calling start twice Check the answer of this question online on QuizOver. Test(int id) { this.28.quizover.out.com .quizover.com/pdf/thread-in-java (313) Powered by QuizOver. What are the possible results of compiling and running the followin.com QuizOver.com: Question: thread in java Permalink: http://www.4.print("main").. } public static void main(String[] args) { Thread t = new Thread(new Test(2)). t.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . start(). Author: JavaChamp Team What are the possible results of compiling and running the following code? public class Test extends Thread { int id.out.1. } public void run() { System. com . t2.out.sleep(100). } catch (InterruptedException e) { } } }. } catch (InterruptedException e) { } } }. Thread.quizover. What are the possible results of compiling and running the followin.out.http://www.1.4.start().out. System..quizover.out.print("t1before"). } } Please choose all the answers that apply: • t1before may be part of th output • t1after may be part of th output • t2before may be part of th output • t2after may be part of th output • an IllegalMonitorStateException will be thrown at run time Check the answer of this question online on QuizOver.print("t2before").print("t2after").29.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . new Thread(t1). System.start().com/pdf/using-wait-and-sleep-in-threads-in-java (314) Powered by QuizOver..com QuizOver.com: Question: using wait and sleep in threads in java Permalink: http://www. wait().print("t1after"). final Thread t2 = new Thread() { public void run() { try { System. Author: JavaChamp Team What are the possible results of compiling and running the following code? public class Test { public static void main(String[] args) throws InterruptedException { Runnable t1 = new Runnable() { public void run() { try { System. print("t2after").start().start(). Thread.com . System.out.com: Question: using sleep and wait in thread in java Permalink: http://www.quizover. } } Please choose all the answers that apply: • t1before may be part of the output • t1after may be part of the output • t2before may be part of the output • t2after may be part of the output • compilation fails • IllegalMonitorStateException is thrown at run time Check the answer of this question online on QuizOver.out.4..print("t1after"). public static void main(String[] args) throws InterruptedException { new Thread(t1).print("t1before"). } System.com/pdf/using-sleep-and-wait-in-thread-in-java (315) Powered by QuizOver. } catch (InterruptedException e) { } } }.print("t2before").30.quizover.sleep(100).com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. What is the possible results of compiling and running the following.1. Author: JavaChamp Team What is the possible results of compiling and running the following code? public class Test { static Runnable t1 = new Runnable() { public void run() { try { System. synchronized (this) { wait()..out. static Thread t2 = new Thread() { public void run() { try { System.http://www. } catch (InterruptedException e) { } } }. t2. com QuizOver.quizover.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.(316) Powered by QuizOver. start(). what necessarily modifications are needed to build a wall by alternating between bricks and cement (brickcementbrickcement.1.4. } } public static void main(String[] args) { Contract contract = new Contract(). isCementLastAdded = true.com QuizOver. } public void run() { contract...contract = contract.31.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } } public boolean isWallDone() { return wall.work(). The idea of this program is to allow two workers to build a wall (w. } (317) Powered by QuizOver... !isWallDone()) { wall. public void putBrick() { if (isCementLastAdded . given the following code.append("brick"). Author: Yasser Ibrahim The idea of this program is to allow two workers to build a wall (which consists of bricks and cement) . Worker(Contract contract) { this.start(). } } public class Contract { StringBuilder wall = new StringBuilder("brick").quizover. putBrick().length() >= 100.) and to avoid as possible. } public void work() { while (!isWallDone()) { putCementLayer().com . boolean isCementLastAdded = false.. one worker monopolizing the work alone ? (choose all what apply) class Worker extends Thread { Contract contract.append("cement"). new Worker(contract). } } public void putCementLayer() { if (!isCementLastAdded .http://www. new Worker(contract). isCementLastAdded = false.. !isWallDone()) { wall. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.com .com/pdf/synchronizing-and-mutlithreading-in-java (318) Powered by QuizOver.sleep() after putBrick() in work() method • synchronize isWallDone() Check the answer of this question online on QuizOver.quizover.com: Question: synchronizing and mutlithreading in java Permalink: http://www.http://www.} Please choose all the answers that apply: • synchronize putBrick() • synchronize putCementLayer() • synchronize work() • add Thread.quizover. i++) { total = total + i.out. What is the output of running the following program? Author: Narendra What is the output of running the following program? class Tester extends Thread { int total.http://www. System.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.start().1.quizover. } } synchronized public void run() { for (int i = 0. System.wait().com: Question: java thread wait notify usage Permalink: http://www.com .quizover.println("waiting for t to complete"). t. i < 3. • it depends upon which thread has got the cpu first . t. synchronized (t) { System.out.out.32.println("total" + t. public static void main(String[] args) throws Exception { Tester t = new Tester(). Check the answer of this question online on QuizOver.println("hi how are you:").total).com/pdf/java-thread-wait-notify-usage (319) Powered by QuizOver. • total 0 is part of the output. • total 3 is part of the output . } } } Please choose only one answer: • main thread will wait indefinitely. } } } A ob1=new A()..i++){ System.i<5.quizover.sleep(2000)."Saurabh").print("Hello").getName()).http://www.33. Check the answer of this question online on QuizOver. Thread ob4=new Thread(ob2.com QuizOver..com/pdf/how-threads-synchronization-works-in-java-nikhil-kumar (320) Powered by QuizOver.start()."Nikhil").com . Thread ob3=new Thread(ob1.currentThread(). args){ class A implements Runnable{ public synchronized void run(){ display(). } } Please choose only one answer: • Compilation Fails • Hello Saurabh Hello Nikhil ..com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .4.com: Question: how threads synchronization works in java nikhil kumar Permalink: http://www.println(Thread..1.quizover. Printed in Synchronized way • Output is Unpredictable .. try{ Thread. A ob2=new A().out. Synchronization issue Author: Nikhil Kumar Synchronization issue class SyncDemo{ public static void main(String. ob4. } catch(InterruptedException e){} System.out.start().. } synchronized void display(){ for(int i=0. ob3.. http://www.com .1.com/pdf/java-synchronized-method (321) Powered by QuizOver. Which three will compile and run without exception ? Author: BELHAUSS Imad Which three will compile and run without exception ? Please choose all the answers that apply: • private synchronized object o.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.quizover.com QuizOver.class){ //code here } } • void go(){ synchronized (o){ //code here } } Check the answer of this question online on QuizOver.34.4. • void go(){ synchronized(){ // code here } • public synchronized void go(){ //code here } • private synchronized (this) void go(){ //code here } • void go(){ synchronized(object.com: Question: java synchronized method Permalink: http://www. 4.com . Chapter: Enums 1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. Enums Questions (322) Powered by QuizOver.quizover.http://www. } int getIndex(){return index. must be marked public • Compilation error at line 10.quizover. Must be terminated by a colon '.1.com .Published.1. // Line 10 } } Please choose only one answer: • Compilation error at line 2.com QuizOver.index + Status. must use getIndex() instead • 3 Check the answer of this question online on QuizOver. Rejected(2).out.index).} // Line 5 } public class Tester { public static void main(String [] args) { System.com/pdf/how-to-declare-java-enum (323) Powered by QuizOver.Rejected.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? enum Status { Published(1). can't access index directly.println(Status. // Line 3 Status(int i) { index = i. // Line 2 int index.' • Compilation error at line 3.http://www.com: Question: how to declare java enum? Permalink: http://www.quizover.4. index must be marked static • Compilation error at line 5. 4.1. enum can be declared and defined inside : Author: Yasser Ibrahim enum can be declared and defined inside : Please choose all the answers that apply: • Another enum • A class • An interface • A method Check the answer of this question online on QuizOver.com .quizover.com/pdf/where-java-enum-can-be-defined (324) Powered by QuizOver.com QuizOver.2.com: Question: Where java enum can be defined? Permalink: http://www.quizover.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . PUBLISHED.quizover. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Test{ enum BookStatus { PUBLISHED.quizover.http://www.com/pdf/comparing-enums-in-java (325) Powered by QuizOver.1.print(s1. s1 and s2 are incorrectly instantiated Check the answer of this question online on QuizOver.equals(s2)).4.PUBLISHED).com QuizOver.com: Question: comparing enums in java Permalink: http://www. System.print(s1 == BookStatus.out.com . System. DRAFT } public static void main(String[] args) { BookStatus s1 = BookStatus. } } Please choose only one answer: • falsetrue • truetrue • falsefalse • compilation error.out. BookStatus s2 = BookStatus.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .3.PUBLISHED. Signal.1.Signal.values()) { System.com QuizOver.Signal.com .println(ele). arg) { for(Signal ele : Signal. Find correct import statement ? Author: Naveen Yadav Find correct import statement ? package pkg.. public enum Signal{GET .4. • static import pkg.quizover. • import static pkg.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Check the answer of this question online on QuizOver.quizover. } } } Please choose only one answer: • import pkg.com/pdf/java-import-statements (326) Powered by QuizOver.. • import pkg.4.com: Question: java import statements Permalink: http://www. GO} ======================== class Import_Enum2 { public static void main(String.http://www.*. SET. • static import pkg. Author: Naveen Yadav Which of following import statement will allow to compile code correctly package pkg.Signal. } } Please choose all the answers that apply: • import static pkg.Signal.SET. • import static pkg.5.Signal. • import static pkg.http://www.SET. Check the answer of this question online on QuizOver.Signal. Which of following import statement will allow to compile code corr. public enum Signal{GET .. arg) { System.com QuizOver.Signal.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .println(SET).quizover.1.com ..*.com/pdf/java-static-imports (327) Powered by QuizOver. SET.. GO} class Import_Enum2 { public static void main(String.4. • import pkg.quizover.com: Question: java static imports Permalink: http://www.. WEST } } public class Sprite{ // insert code here } Please choose only one answer: • Direction d = NORTH. inserted at line 14. inserted at line 14.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.com: Question: java enum constructor Permalink: http://www.com . • Nav.quizover.com/pdf/java-enum-constructor (328) Powered by QuizOver. allows the Sprite class to compile? Author: BELHAUSS Imad Which code. • Nav.quizover. SOUTH. EAST.NORTH. Check the answer of this question online on QuizOver.Direction d = Nav.4.1.NORTH. allows the Sprite class to compile? class Nav{ public enum Direction { NORTH.http://www.6.Direction d = NORTH. • Direction d = Direction.Direction. Which code. size).println(drink.com . BIG . public class Coffee { CoffeeSize size.com/pdf/question-alinaioana-florea-enum-and-methods (329) Powered by QuizOver. drink.BIG. // line 1 public static void main(String.. NORMAL.7. System. } Coffee drink = new Coffee().4.out. What is the result of running the following code? . arg) // line 2 { enum CoffeeSize{ SMALL..com: Question: AlinaIoana Florea enum and methods Permalink: http://www.http://www.1.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Author: AlinaIoana Florea What is the result of running the following code? .size = CoffeeSize.quizover. // line 3 // line 4 // line 5 } } Please choose all the answers that apply: • big • compile-time error on line 1 • compile-time error on line 2 • compile-time error on line 3 • run-time error on line 4 Check the answer of this question online on QuizOver.quizover.com QuizOver. meow.quizover. Author: AlinaIoana Florea Will the following code compile? . this.com QuizOver.http://www.woof.sound = sound. int nrOfLegs) { this(sound). } public int getNrOfLegs() { return nrOfLegs. 4). BURBLE // line 1 } // line 2 strictfp enum Animal { DOG(AnimalSound. "default" or "strictfp" modifiers (330) Powered by QuizOver. there will be a compile-time error on line 2 because of the missing semicolon(. } public AnimalSound getSound() { return sound. } }. // line 4 FISH(AnimalSound.com . private int nrOfLegs.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .BURLE) // line 5 { public int getNrOfLegs() { return 1.4. can be marked with only the "public". } Animal(AnimalSound sound) { this.nrOfLegs = nrOfLegs. // line 6 private AnimalSound sound. } }. like any top class. static final enum AnimalSound { WOOF. Will the following code compile? . // line 7 Please choose all the answers that apply: • No.1. // line 3 CAT(MEOW.) and on line 6 because of the present semicolon • There will be a compile-time error on line 3 and 5 • There will be a compile-time error on line 4 • There will be a run-time error on other lines • AnimalSound. 4). Animal(AnimalSound sound.8. http://www.• An enum.g.com/pdf/enum-constant-specific-class-body (331) Powered by QuizOver.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.quizover. can NOT be marked "strictfp" Check the answer of this question online on QuizOver. Animal. e.com: Question: enum constant specific class body Permalink: http://www.com . 9. protected enum Animal { DOG.1.http://www.com QuizOver. What will the following code output? .quizover.values().com: Question: AlinaIoana Florea instantiating an enum. } } } Please choose all the answers that apply: • DOG DOG cat FIsh • Compilation error on line 1 • Compilation error on line 2 • Compilation error on line 3 • Compilation error on line 4 Check the answer of this question online on QuizOver. and using its values() and access modifiers Permalink: http://www.com .println(woofy). FISH } // line 1 public class TestEnumAnimal { Animal[] animals = Animal.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out. // line 2 static Animal woofy = new Animal().quizover.out.com/pdf/question-alinaioana-florea-instantiating-an-enum-and-using-its-values- (332) Powered by QuizOver.. arg) { System. Author: AlinaIoana Florea What will the following code output? ..4. for (Animal animal : animals) { // line 4 System.println(animal). // line 3 public static void main(String. CAT. com . public getAnimal() { return animal.1. // line 1 }.http://www. } void play(){} } public class Test { public static void main(String[] args) { for(AnimalSound sound: AnimalSound. (333) Powered by QuizOver. A fish makes BURBLE and has 4 legs. } AnimalSound(String animal) { this.animal = animal.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .println("A " + sound.com QuizOver. meow("CaT").quizover. private String animal. A CaT makes meow and has 4 legs. public static int nrOfLegs = 4. } } } Please choose all the answers that apply: • The enum's constants are printed in the order in which they were declared: A dog makes WOOF and has 4 legs.animal + " makes " + sound + " and has " + AnimalSound. } enum AnimalSound extends Sounds implements PlaySounds { WOOF("dog").").values()) { System. CHIP_CHIP } interface PlaySounds { void play().10.out. BURBLE("fish") { int nrOfLegs = 1.nrOfLegs + " legs.4. What's the output of the following code? Author: AlinaIoana Florea What's the output of the following code? enum Sounds { HAM_HAM. • • • • Compilation error: an enum can not extend any class.com/pdf/enum-extends-implements-encapsulation (334) Powered by QuizOver.com: Question: enum extends implements encapsulation Permalink: http://www.http://www. should be made "public" Compilation error: in main() you can NOT access sound.com QuizOver.animal because "animal" is private in AnimalSound Check the answer of this question online on QuizOver.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . so remove "extends Sounds" from its declaration Compilation error: getAnimal() from AnimalSound is missing a String return type Compilation error: play() is NOT correctly implemented in AnimalSound as it has a more restrictive access level of "default".quizover.quizover. Data Types Questions (335) Powered by QuizOver. Chapter: Data Types 1.com .com QuizOver.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.quizover. 1.out.com .http://www. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { static void test(float x) { System.print("float").com QuizOver.1. } public static void main(String[] args) { test(99.com: Question: Primitive Data types in java Permalink: http://www. } static void test(double x) { System.4.9).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.print("double"). } } Please choose only one answer: • float • double • Compilation error • Exception is thrown at run time Check the answer of this question online on QuizOver.quizover.quizover.com/pdf/primitive-data-types-in-java (336) Powered by QuizOver. quizover.com . } static void test(double x) { System.out.com/pdf/float-data-type-in-java (337) Powered by QuizOver.4.2. } public static void main(String[] args) { test((float) 99.com: Question: float data type in java Permalink: http://www. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? public class Tester { static void test(float x) { System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver.9).quizover.http://www.out.print("float").1.print("double"). } } Please choose only one answer: • float • double • Compilation error • Exception is thrown at run time Check the answer of this question online on QuizOver. com .1.print("float"). } public static void main(String[] args) { test(99.out.4.com: Question: Data types in java Permalink: http://www. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? public class Tester { static void test(float x) { System.com QuizOver. } } Please choose only one answer: • float • Compilation fails • An Exception is thrown at run time Check the answer of this question online on QuizOver.quizover.http://www.quizover.9).com/pdf/data-types-in-java (338) Powered by QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .3. .1.quizover. //LINE 3 byte b1=(byte)s1 +(byte)s2.com .. //LINE 4 byte b2=(byte)((byte)s1 +(byte)(byte)s2).4. //LINE 2 short s3= s1+s2.com/pdf/java-primitves-byte-short-int-long-type-casting (339) Powered by QuizOver. which of the followings are correct when tried to compile and execu.com QuizOver. //LINE 1 short s2 = s1+=s1. //LINE 5 }} Please choose all the answers that apply: • compile time error at LINE 1 • compile time error at LINE 2 • compile time error at LINE 3 • compile time error at LINE 4 • compile time error at LINE 5 • compiles successfully.http://www.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com: Question: java primitves byte short int long type casting Permalink: http://www.quizover. Author: Pankaj Gupta which of the followings are correct when tried to compile and execute the below code ? class s { public static void main(String agr[]) { short s1=4. Check the answer of this question online on QuizOver.4. quizover. if byte b=50.http://www.com: Question: java automatic type conversion Permalink: http://www.1. Please choose only one answer: • error ! can't assign an int to a byte • b=100 • b=50 Check the answer of this question online on QuizOver.4.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .5.com/pdf/java-automatic-type-conversion (340) Powered by QuizOver.quizover. b=b*2.com . b=b*2. Author: Shashikant Jaiswal if byte b=50. com QuizOver.0 Check the answer of this question online on QuizOver.quizover.com: Question: java int float widening Permalink: http://www.0 • 1.println(++f).4.quizover. // line 1 System.com . What is the correct output? Author: MrDick What is the correct output? class Test { public static void main(String[] args) { float f = 1.1.com/pdf/java-int-float-widening (341) Powered by QuizOver.6.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www. // line 2 } } Please choose only one answer: • compilation error in line 1 • compilation error in line 2 • Runtime exception • 1 • 2. Static and init blocks Questions (342) Powered by QuizOver.4.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . Chapter: Static and init blocks 1.com .http://www.com QuizOver.quizover. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? class Bird { static { System. } static { System.out. } public static void main(String[] args) { System. } } public class Falcon extends Bird { Falcon(){ System.print("static2 ").print("static1 ").com .print("init3 ").print("Falcon ").quizover.out.http://www. } public Bird() { System.print("Bird ").1.com/pdf/in-what-order-static-and-init-blocks-get-called-in-java (343) Powered by QuizOver.4.1.quizover.out.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .out.out. } { System.out. new Falcon(). } } Please choose only one answer: • main static1 static2 init3 Bird Falcon • main static1 static2 Falcon init3 Bird • main static1 static2 Falcon Bird init3 • static1 static2 main init3 Bird Falcon • static1 static2 main Bird init3 Falcon Check the answer of this question online on QuizOver.com QuizOver.com: Question: In what order static and init blocks get called in java? Permalink: http://www.print("main "). quizover.http://www.4. Chapter: Serialization 1.com .com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .com QuizOver. Serialization Questions (344) Powered by QuizOver. import java.io. is.http://www.Serializable. try { FileOutputStream fos = new FileOutputStream("data.com/pdf/how-to-combine-inheritance-and-serialization-in-java (345) Powered by QuizOver. import java.readObject().com . class Base { int code = 99. import java. ObjectOutputStream os = new ObjectOutputStream(fos).txt"). System.ObjectInputStream.1.quizover. import java. ObjectInputStream is = new ObjectInputStream(fis). os.quizover.close(). os.ObjectOutputStream.print(derived2.txt").FileInputStream.FileOutputStream.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .writeObject(derived1).io.com: Question: How to combine inheritance and serialization in java? Permalink: http://www.io.4.com QuizOver.io.code). derived1. } } public class Derived extends Base implements Serializable { public static void main(String[] args) { Derived derived1 = new Derived(). } catch (Exception x) { } } } Please choose only one answer: • 0 • 77 • 88 • 99 • Compilation error Check the answer of this question online on QuizOver.io.close(). Base() { code = 77.out.1.code = 88. Derived derived2 = (Derived) is. FileInputStream fis = new FileInputStream("data. What is the result of compiling and running the following code? Author: JavaChamp Team What is the result of compiling and running the following code? import java. http://www.(346) Powered by QuizOver.com QuizOver.com .quizover.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . } Please choose only one answer: • Compilation error • Exception is thrown at run time • Serialization will succeed correctly with no problems Check the answer of this question online on QuizOver..quizover. what may hap.com .com QuizOver.com: Question: How to serialize java class? Permalink: http://www. Author: Yasser Ibrahim Given the following two classes (Address and Account).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved . what may happen if you attempt to serialize an instance of Account? class Address{} class Account implements Serializable {Address address.http://www.2.quizover..com/pdf/how-to-serialize-java-class (347) Powered by QuizOver.1. Given the following two classes (Address and Account).4. com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.quizover.4.quizover.com: Question: What variables cannot be serialized in java? Permalink: http://www.3.1. Which of the following data members of a class cannot be serialized? Author: JavaChamp Team Which of the following data members of a class cannot be serialized? Please choose all the answers that apply: • private data members • transient data members • static data members • final data members Check the answer of this question online on QuizOver.com/pdf/what-variables-cannot-be-serialized-in-java (348) Powered by QuizOver.com QuizOver.com . } catch (Exception x) { System. Tester tester2 = (Tester) is. System.out.ObjectOutputStream.readObject().1. What is the result of compiling and running the following code? Author: Yasser Ibrahim What is the result of compiling and running the following code? import java.txt")). public static void main(String[] args) { Tester tester1 = new Tester(). import java.println("Exception thrown").io.out.com: Question: What cannot be serialized in java? Permalink: http://www.print(++tester1. public class Tester implements Serializable{ transient int x = 5. System.close(). import java.http://www.FileOutputStream. } } } Please choose only one answer: • 55 • 65 • 60 • An exception is thrown Check the answer of this question online on QuizOver.close().io.quizover. import java.io.4. os. os.out.FileInputStream. try { ObjectOutputStream os = new ObjectOutputStream( new FileOutputStream("data.Serializable.quizover.io.ObjectInputStream.4.writeObject(tester1).com .println(tester2.x + " "). import java.com QuizOver.com/pdf/what-cannot-be-serialized-in-java (349) Powered by QuizOver. ObjectInputStream is = new ObjectInputStream(new FileInputStream( "data.io. is.x).com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .txt")). io.5. } static {System. }catch(Exception e){ System.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .http://www.print("a-").com QuizOver. oos.out. ois = new ObjectInputStream( new FileInputStream ("myFile")). Which of the following is the correct output: Author: Juan Pablo Which of the following is the correct output: import java.out.out.readObject().print("a1-"). ObjectOutputStream oos = null.writeObject(subClass).} public Class() { System.print("b1-").out.print("s2-"). subClass = (SubClass) ois.quizover.com . class Class { {System.out.4. try{ oos = new ObjectOutputStream(new FileOutputStream("myFile")). } } } Please choose only one answer: • s1-s2-a1-a-b1-b-a1-a-b1-b • s1-s2-a1-a-b1-b-a1-a• s1-s2-a1-a-b1-b• Todo mal! • ClassCastException is thrown (350) Powered by QuizOver.} public SubClass() { System.print("b-").1.print("s1-").out.*.} } public class TestSerializable { public static void main(String[] args) { SubClass subClass = new SubClass().out. } static {System.print("Todo mal!"). ObjectInputStream ois = null.} } class SubClass extends Class implements Serializable { {System. http://www.com/pdf/serialization-objects-constructors-and-initialization-blocks (351) Powered by QuizOver.com .com: Question: serialization objects (constructors and initialization blocks) Permalink: http://www.com QuizOver.com is the leading online quiz & exam creator Copyright (c) 2009-2014 all rights reserved .quizover.Check the answer of this question online on QuizOver.quizover. Documents Similar To Sun Certified Java Programmer Scjp ExamSkip carouselcarousel previouscarousel nextCPP MCQtcs30PortingTataTechnologiesPlacementPapersSampleMELJUN CORTES JEDI Slides Intro2 Chapter00 Introductionc#reu proposalmcqs for all unitsexplanations speech46275538 Java Interview QuestionsNametcs+CSerializationbegin c - class6Java advantages over c++D EE Parts II & III(SUKHENDU).pdfC BasicsUTD Human Resource Plan Templatec Programming NotesKRL Reference Guide v4 1library management systemCcs c ManualPackages 2javacodingstandard_GDLHow to Program an 8 Bit Microcontroller Using C - AtmelL0 Programming EnvironmentIct SyllabusFlex Tronic sJava GameMore From IamSajid JatoiSkip carouselcarousel previouscarousel next1Java Intro (1)Java Course OutlinesJava Programmings2Mobile Technology 2013 2014 RsAssignment Brief 2014-15Worksheet4 Setsc Mps 161 Class Notes Chap 0714317288s46478Java Course OutlinesssJava ProgrammingMathJava SE 7 Association CertificationsAssignmmet Math 3Welcome FaxChange ManagementcardsEmpire Registration Form Change ManagementsComplainwPor FolioCoversEdexcel Level7 SMLfFrontline Staf Application FormBook1LewinAdkar and Kotter difference and organization structure.txtApplication for EmploymentBest Books About Class (Computer Programming)Java : The Complete Reference.by Harry. H. Chaudhary.C++ MCQs: Multiple Choice Questions and Answers (Quiz & Tests with Answer Keys)by Arshad IqbalJava 8 Programmer II Study Guide: Exam 1Z0-809by Esteban HerreraPython 3 Object-oriented Programming - Second Editionby Dusty PhillipsJava: Programming: Your Step by Step Guide to Easily Learn Java in 7 Daysby iCodeAcademyCore Java Professional : Advanced Features (Core Series) Updated To Java 8.by Harry. H. Chaudhary.Footer MenuBack To TopAboutAbout ScribdPressOur blogJoin our team!Contact UsJoin todayInvite FriendsGiftsLegalTermsPrivacyCopyrightSupportHelp / FAQAccessibilityPurchase helpAdChoicesPublishersSocial MediaCopyright © 2018 Scribd Inc. .Browse Books.Site Directory.Site Language: English中文EspañolالعربيةPortuguês日本語DeutschFrançaisTurkceРусский языкTiếng việtJęzyk polskiBahasa indonesiaSign up to vote on this titleUsefulNot usefulMaster your semester with Scribd & The New York TimesSpecial offer for students: Only $4.99/month.Master your semester with Scribd & The New York TimesRead Free for 30 DaysCancel anytime.Read Free for 30 DaysYou're Reading a Free PreviewDownloadClose DialogAre you sure?This action might not be possible to undo. Are you sure you want to continue?CANCELOK
Copyright © 2024 DOKUMEN.SITE Inc.