<AptiCode/>

The ultimate platform for developers to practice, compete, and grow. Join our community of passionate coders today.

TwitterLinkedIn

Platform

ProblemsCompilerAptitude TestsContests

Company

About UsContactRewardsContribute

Legal

Terms of ServicePrivacy PolicyShipping PolicyRefund Policy

© 2025 AptiCode. All rights reserved.

Made withfor developers

topic/Java Programming

Question NoTitleTypeMarks
770.public class Test2 { public static int x; public static int foo(int y) { return y * 2; } public static void main(String [] args) { int z = 5; assert z > 0; /* Line 11 */ assert z > 2: foo(z); /* Line 12 */ if ( z < 7 ) assert z > 4; /* Line 14 */ switch (z) { case 4: System.out.println("4 "); case 5: System.out.println("5 "); default: assert z < 10; } if ( z < 10 ) assert z > 4: z++; /* Line 22 */ System.out.println(z); } }which line is an example of an inappropriate use of assertions?
MCQ
5
727.You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
MCQ
5
728.public class Outer { public void someOuterMethod() { //Line 5 } public class Inner { } public static void main(String[] argv) { Outer ot = new Outer(); //Line 10 } }Which of the following code fragments inserted, will allow to compile?
MCQ
5
729.interface Base { boolean m1 (); byte m2(short s); }which two code fragments will compile?interface Base2 implements Base {}abstract class Class2 extends Base{ public boolean m1(){ return true; }}abstract class Class2 implements Base {}abstract class Class2 implements Base{ public boolean m1(){ return (7 > 4); }}abstract class Class2 implements Base{ protected boolean m1(){ return (5 > 7) }}
MCQ
5
730.Which three form part of correct array declarations?public int a [ ]static int [ ] apublic [ ] int aprivate int a [3]private int [3] a [ ]public final int [ ] a
MCQ
5
737.public void foo( boolean a, boolean b) { if( a ) { System.out.println("A"); /* Line 5 */ } else if(a && b) /* Line 7 */ { System.out.println( "A && B"); } else /* Line 11 */ { if ( !b ) { System.out.println( "notB") ; } else { System.out.println( "ELSE" ) ; } } }
MCQ
5
738.switch(x) { default: System.out.println("Hello"); }Which two are acceptable types for x?bytelongcharfloatShortLong
MCQ
5
740.public class While { public void loop() { int x= 0; while ( 1 ) /* Line 6 */ { System.out.print("x plus one is " + (x + 1)); /* Line 8 */ } } }Which statement is true?
MCQ
5
761.void start() { A a = new A(); B b = new B(); a.s(b); b = null; /* Line 5 */ a = null; /* Line 6 */ System.out.println("start completed"); /* Line 7 */ }When is the B object, created in line 3, eligible for garbage collection?
MCQ
5
762.class HappyGarbage01 { public static void main(String args[]) { HappyGarbage01 h = new HappyGarbage01(); h.methodA(); /* Line 6 */ } Object methodA() { Object obj1 = new Object(); Object [] obj2 = new Object[1]; obj2[0] = obj1; obj1 = null; return obj2[0]; } }Where will be the most chance of the garbage collector being invoked?
MCQ
5
Current Page: 1
  • Prev
  • 1
  • 2
  • 3
  • Next