You are on page 1of 10
REGISTRATION | exam Welcome | Logout | RePoRTS | PROFILE Report Details 2 3 Attended Question and their Answers Test vest Test vest Est Est Est Est Est vest vest vest vest Name Exam Type Assessment Assessmen! Assessment Assessment Assessment Assessment Assosement Assossmy Assessment Assessment Assessment Kr MCO-Testt-030218 Kir jove-n21218 kreMca.022418 kIrMoa.031716 KiTsMca-rt-052218 kreMca.052418 KIT-APEH- 260518 KIT-JUNIT-2605°8 KIT-JUNIT2-2005°8 KITAGESTS-200518 KITFULL-300518 KITAVGe-300518 KIT-S1_3105%8 Questo 1s the following declaration for interface Bendable correct and free of compilation error? abstract interface Bendable { // line 1 ‘final. ine x = 2009 void methodi() j // line 5 public static class angle () // Tine 6 options: Rives, this is a correct and free Bit, compilation enror at Line 2 Cito, compilation enror at Line 3 Dito, compilation enror at Line § E.tio, compilation error at Line 6 if Tine’ ff error declaration abstract should be removed X should be declared public final nethod methodi() should be declared public abstract Exam Date oanaz018 27022018 2ain2i20%8 srosi2018 2ainsi20%8 2410512018 26i0si2018 2610512018 2ainsi20%8 2ainsi2016 s0insi2018 suinsi2o18 suinsizo18 Can't declare a clase inside an interface |Will the following code compile correctly? abstract class AirPlane { y abstract void f1y()5 void land() { // Line s systen.out.print("Landing..") ¥ class Airjet extends Airplane { Airdet() { super()3 // line 14 t void fly) { System.out.print("Flying. Yes, it will compile with no errors No, because at line 5 method land() must be abstract since clase AirPlane is abstract No, because class AirJet must override method land() No, because at line 14 AirJet constructor is calling the super() nile AirPlane has no constructor defined ps 72.65.17 408 PacemenCarmonAcion spoarcanlingtnatoneoraneack tn ‘tal Marks oo 0 oo oo oo oo oo oo oo oo oo oo oo Mark View Questionaire View Questionaire View Questionaire View Questionaire View Questionaire View Questionaive View Questonaive View Questionaire View Questionaire View Questionaire View Questionaire View Questionaire View Questionaire student TOTAL SCORE 10 e Mark cored 110 oo 10 10 ip... 17408 Pcementerwroctonctprensat ‘he fotlaing cade contine sconllatin error what can be cone to fix this ever Independently? Bieriet dot titsiane ¢//2ise satrect old A190) I line 2 vote ned Syren. ou. print Lanne." > huss atroet eens atreane ( // Le 10 esto steer 11 Mine 3 > toss nyo ¢ Shen ot. prnt Pyne "35 > Deseret votd ant) 1/ tin 20 tract from Line 20 and a bd to pth Lad) ard 8. Renove abstract fron Line 20 ond edt body to method Lard() or Declare clare sire sr abetract to #8 ine 30 c Mich of the following ¢ true? fnsvers: a ae 3 class 1s declared abstract , st must contain at least one abstract method 2. Ifa class 45 declared abstract 5 oll'Ies methods must be abstract, 3. —Aimethod can either be Final of dbstract 4) Gra natnod Ss abstract then Sts clace must be declared abstract 5: an abstract method has no body and ends with « semicolon options: Ae aLL ane correct 8. All are not correct €. ALL ane correct except 2 B.A are not correct except 2 D Which of the following variables is incorrectly declared? public abstract interface Bouncable t 5 int a = 05 public int b = 15 public static int c= 2 public static transient int d = 3; public final int e = 3; public static final int f + options: A a B. b Ics c D. d E. e F. f c Three of the methods are incorrectly declared, which are they? public abstract class Tester { public void test1()3 public final void test2() {33 public static void test3() {}3 public abstract static void testa(); public abstract final void test5(); t Please choose only one answer: testl , test2 and testa test2 , testa and tests test1 , testa and testS None of these > 10 10 00 00 Considering the following declaration fan interface Convertable, wich oF the Falloning code public interface Convartabie { Ine convereTatnt(); chan convereTocnar(); Pease choose all the answers that apply! 1. class bight taplements Convertable { public chan convertTothar() { retuon @ pubic ane converctorne() Feu 6} y 2 abstract class Oigit implements Convertable { Int canverttotnt() 3 char convoretachar; 3. abstract class Digit inplenents Convertable { public int convertToine() {retum es) 4, sbsteact class Digit Anplenents Convertable { public int convertTorne() {return @; + ‘han convertracnar()3, y 5. class Digit inplenents Convertable { int convertTotne() {return O5 ) chan convereTothar() { retumm O } 5. Antenface Roundable extends Convertable { ine ronan); } Options Ao 4,3 and 5 are Correct 5. 1)2 and 6 are Cormect oe AGF aT AEN Zt. public abstract class Digit { public abstract void print(); } Me. public class Digit { public abstract void print(); } a. public abstract class Digit { public abstract void print(){} } a public abstract class Digit { public void print();} I public class Digit { public void print(){};} AL 182 oo : pam ey ; Se ya wee ; i = mark m2() "public™ 7 ps 72.65.17 408 PacemenCarmonAcion spoarcanlingtnatoneoraneack tn 10 oo 00 " 2 What is the correct output? interface Father { public void go(); } interface Mother { public void go(); } class Tester implements Father, Mother { // line 1 @override public void go(){ // line 2 system. out.print1n("Child") ; } public static void main(String args[]) { new Tester().go(); // line 3 } } Options: A. Compilation error in line 1 B. compliation error in line 2 c. child D. compilation error in line 3 c 10 F oo Wihet is the expected output? import java.io.10Exception; clase Father { public Father() throws IOException { Systen.out.print ("Father"); throw new IO0Exception(); + > class Son extends Father { public Son() throws IOException System.out print ("son"); ) 3 public class Tester { public static void main(string[] args) ( try new Son(); } catch (IOException e) { System.out.print("Inside catch"); ) > > options: AR. Compile error, constructors can't throw Exceptions 8. —-Fatherson C.FatherInside catch D. Father, then an IOException is thrown =z Son Fl Sontnside catch c 10 8 oo ps 72.65.17 408 PacemenCarmonAcion spoarcanlingtnatoneoraneack tn a0 a “ 6 ‘ihat iz the expected output of compiling and running this code? class Father ( public Father() throws Runtineexception { Systom.out print("rather"); ‘throw new Runtimetxception(); y » cass Son extends Father { public Son() throws Runtimakxception { System.out .print("Son"); y public class Tester { public static vold main(stringl] ares) { rrew Son(); // line 17 y ? Options a compile error, an import to java.Lang.Runtinetxception is required 8 Father uill be printed then @ RuntineException would be thrown ic Conpile error at line 17, new Son() should be within a try/eatch block 5 ‘Son e Senather F Fatherson ee e 10 8 10 Bak fe topcted rept of cnplng ond morn the flowing es clase Airplane ible Adreuane()_ syetam out. prine(AePLane"); , clase Aitaet extends Airplane { obite alraee() trone Toeeception ( tne ‘on non TobxceptHon()5 ) catch (Goeneaption «) { ‘yaten.outpetne("TobAception He throw in Aire"); . pubtic clase Tester { plbide statis vols main(String sree{]) ( tt ow air3ee0)5 2 eaten €Iobseepton e) { “Syeeomoutsprint("2obscoption 4s thrown sn Testar")s > > options 2. skSteiSnezoescopeson 2 envoy £9 Testers will be pranees 5. canpiiacion ercor Oc e 10 A oo [lat fs the expected ovtaut of consing and runing te flora code? Inport Java.t0.r08xception; lass alrpiane ( PUblie AisPLene() throws ToExceptéon, muntimeéxception { ‘system. ovt.printincoaurbLane®) 5 » d lass siraet extends AiePlane { } // Line 7 public clase Soster (| publi Static vols nain(string srgst]) throws ToException { // Line 16 ew AirPlane(); // tine th ? } options: Compile error at dine 1e, main() must throw also Runtinesxception 5! Compile error at Line 11° ,new AirPlane() must be within ry/eatch block ce 10 8 oo What is the expected output? interface Folceble ( ‘public void fold() throws Exception, ‘ass Paper inplenents Foldable ( public vote fola() { // line © Systen.out.print ("Pola public clase Tester { public static void main(string ergs []) Foldable obji = new Papers opja.fold(); // ine 8 Paper obj2'" nen Paper(); // Line 18 oojz.folat); d > options A FotaFote 8. Gomplation error at Line 6, fold() must declare at header throws exception €!— Campiation error at Line 8, Unhandled exception D.—Runtinetxeeption at Line 8 £! Compilation error at Line 10, unhandled exception ps 72.65.17 408 PacemenCarmonAcion spoarcanlingtnatoneoraneack tn 10 6 wv ° _ 8 wc What is the result of compiling and running the following code? public clase Tester { public static void main(stringt] ange) { Syetem.out.prine("4")3, ty systen.out print(*2"); System-exdt(@); } finanny System.out-print("3")5 ; > ) options: a as C.Conpitation error , there should be at least one caten before Finally 8 10 A lihat is the result of compiling and running the following code? public class Tester { public static void main(string[] args) { system.out.print ("1"); try { return } catch (Exception e) { Systen.out.print("2"); } finally { Systen.out print ("3"); d System-out.print ("4"); t } Please choose only one answer: AL 3234 8. 1B Ea 1 D. Compilation error . 10 What is the result of compiling and running the following progran? public class Taster { public static void main(stringl] args) { try { ‘throw new Runtimetxception(); } catch (Runtimetxception e) { Systen.out. printin( "Runtimetxception") } catch (Arithmeticexception e) { System.out. printin("Arithmeticexception"); } catch (Exception e) { Systom.out.printin(“exception”) ; y + d options: 8 “RuntineBxception” is printed 8 "Exception" is printed c warithmeticexception” is printed ° conpiiation error c 10» ps 72.65.17 408 PacemenCarmonAcion spoarcanlingtnatoneoraneack tn oo 00 00 00 Wihat is the result of compiling and running the following code? public class Tester { static void method() throws Exception { throw new Exception(); Public static void main(String[] args) { try { method(); } catch (Throwable e) { try { throw new Exception() 5 } catch (Exception ex) { System. out print(“exception" } finally { System.out print ("Finally"); y + } } Options: AL “exception” is printed 8. “Finally” is printed c. “exceptionfinally" is printed D Compilation error 20 b won oo What is the result of compiling and running the following code? public class Tester { static void method(){ ‘throw new Exception(); , public static void main(string[] args) { try { methed(); } catch (Throwable e) { try { throw new Exception() ; } catch (Exception ex) { System.out. print(“exception") } finally { System.out.print(“Finally"); } + + } options: AL exception 8. finally & exceptionfinally D. Compilation error 2 © wc 10 What is the result of compiling and running the following code? public class Tester { public static void main(String[] args) { String stmt = "Javachanp 20@9"; String[] arr = stmt.split(" "); try { int x = Integer.parsetnt(arr[1])5 System.out.print (x); } finaly { System.out.print ("Finally"); ¥ } 2 Options: A 2608 8. Finally lo. 2009Finally D. No output will be produced gE. Compilation error 2 c wc 10 p26. 400 cemancenmontton eprops tn m0 2 24 26 ip... 17408 Pcementerwroctonctprensat What is the result of compiling end running the following code? public class Tester { public static void main(string{] args) ¢ ‘String stmt = "javachamp 2009"; String[] arr = stmt.split(" "); try { int x = Integer. parsetnt(arr[0]); ‘System. out. print(x); } catch (Exception e) { system.out .print("catch"); } #inanay { ‘System. out. print ("finally"); } Options: 2009 2e09Finally catchfinally No output will be produced Compilation error 2e08catchFinally In which case a NoClassDefFoundError will be thrown? Options: A. When try to compile a non found java file B. When try to run a non found java .class file a. When try to compile a non found java file What is the output of the following code public class Tester { public static void main(String[] args) { Double d = -4.05 try { a /= 9; } catch (Arithmeticexception e) { System. out.print1n("EXCEPTION!") ; } finally { ‘System.out.printin(d) ; + } + Please choose only one answer: A NotANumber B. NaN ic. EXCEPTION! -4.0 D. -Infinity E. EXCEPTION! 0.0 F. Compilation fails 10 00 00 2% 2 ip... 17 408 Pacemeniarwrnacton dpe What is the output for the below code ? package com; class Animal { public void printName(){ System.out .printin("Animal"); } } package exam; import com.Animal; public class Cat extends Animal { public void printName(){ System.out .printin("Cat"); } } package exam; import com.Animal ; public class Test { public static void main(string[] args){ Animal a = new Cat(); a.printName(); } + : Options: A.Animal B.Cat C.Animal Cat D.Compile Error A 10 A 10 What is the output for the below code ? package bean; public class Abe { public static int index_val = 10; : package com; import static bean.Abc.index_val; public class Testi { public static void main(String... args) { System. out .printIn(index_val); } } Options: A.18 B.compile error, index_val not defined C.Compile error at import static bean.Abc.index_val; D.None of the above 8 108 oo What is the result of compiling and running the following progran? public class Tester { final static int x[] = new int[5]; public static void main(string{] args) { final int x = new Tester().x[5]; if (x @ 10) System. out.printin("Javachamp"); } > Options A. Compilation error 8. —_ArrayIndexOutofBoundsException is thrown & Javachanp D. No output is produced 8 10 A oo 2 30 hat is the expected output? public class Tester { private Tester(int w) { // line 1 System. out.printin(); » public Final Tester() { // line 5 System. out.printin(1¢); » public static vold main(string argef]) { Tester obj = new Tester(50); , ¥ Please choose only one answer: A Won't compile because of line (1) - constructor can't be private 8 Won't compile because of line (5) - constructor can't be final c. 5° 9. 16 E 5e 8 10 8 10 lihich of the Following is true? Please choose all the answers that apply 1. When a class marked final, it cannot be extended 2. When a method marked final, it cannot be overridden 3. When a method marked final, it cannot be overloaded 4) Local variables of @ method cannot be Final 5. A -variable of a primitive type (int,float,..) which marked final, ite value at initialization cannot be changed options: AL 1,34 are correct 8. 1,2)5 are correct call’ are Correct DB. ALL are Wrong. 8 woe a0 Correct the Fellini code final class x2 Final 24() { System.out-orint(8); } // Line 2 Final int 8 = 3; ‘Hal private void dastutf() () // Tine 2 lass x2 extends x1 // Line 3 ‘ final int 8 = 95 Final static void dostuff() ( systen.out.printin(*hello fom 2"): ) : public class Test extends x2 ‘ public totic vedi main(Strspat] imi) c aostutfO;, neu Test) doSturF()s seatie void aastutt() {} // Line vols dostuff(int ars) {_ System out-printla("helle fron Test*); } J/ Line 5 ) de Ethie Gan oot webs owrcomstructor Tif becouse $8 Git Gili Sta. 0" It can not be anjuoy ovenntdden 2. Looe 3°" Gan nat extend/subclase a final clase Se Cen etc dred he come varie ol etl noes ete Scape pcinaylil 2. ine’ -"can nat overrige 9 final dnherdted nethod 6. Line 2» “final” ean not be nixed with "private" Options « she" one cormect (@ karpagar Universty - Al Rights Reserved 2015 ps 72.65.17 408 PacemenCarmonAcion spoarcanlingtnatoneoraneack tn rao

You might also like