Which of the following statements is true?
Which three statements are true?
Which statement is true?
Which statement is true about assertions in the Java programming language?
Which of the following statements is true?
Which of the following statements is true?
public class Test{
public static int x;
public static int foo(int y)
{
return y * }
public static void main(String [] args)
{
int z = assert z >/* Line*/
assert z >foo(z); /* Line*/
if ( z < 7 )
assert z >/* Line*/
switch (z)
{
caseSystem.out.println("4 ");
caseSystem.out.println("5 ");
default: assert z < }
if ( z <)
assert z >z++; /* Line*/
System.out.println(z);
}
}
which line is an example of an inappropriate use of assertions?What will be the output of the program?
public class Test
{
public static void main(String[] args)
{
int x =
assert (x >? "assertion failed" : "assertion passed" ;
System.out.println("finished");
}
}
public class Test
{
public void foo()
{
assert false; /* Line 5 */
assert false; /* Line 6 */
}
public void bar()
{
while(true)
{
assert false; /* Line*/
}
assert false; /* Line*/
}
}
What causes compilation to fail?public class Test
{
public void foo()
{
assert false; /* Line 5 */
assert false; /* Line 6 */
}
public void bar()
{
while(true)
{
assert false; /* Line*/
}
assert false; /* Line*/
}
}
What causes compilation to fail?What will be the output of the program?
public class Test
{
public static int y;
public static void foo(int x)
{
System.out.print("foo ");
y = x;
}
public static int bar(int z)
{
System.out.print("bar ");
return y = z;
}
public static void main(String [] args )
{
int t = assert t > 0 : bar(7);
assert t > 1 : foo(8); /* Line*/
System.out.println("done ");
}
}
What will be the output of the program (when you run with the -ea option) ?
public class Test
{
public static void main(String[] args)
{
int x =
assert (x >: "assertion failed"; /* Line 6 */
System.out.println("finished");
}
}
public class Test{
public static int x;
public static int foo(int y)
{
return y * }
public static void main(String [] args)
{
int z = assert z >/* Line*/
assert z >foo(z); /* Line*/
if ( z < 7 )
assert z >/* Line*/
switch (z)
{
caseSystem.out.println("4 ");
caseSystem.out.println("5 ");
default: assert z < }
if ( z <)
assert z >z++; /* Line*/
System.out.println(z);
}
}
which line is an example of an inappropriate use of assertions?