-
Given the two methods:
void f() throws IOException Which of the following is/are correct overriding method? a) void f() throws IOException b) public void f() c) void f() throws FileNotFoundException d) void f() throws Exception
-
Which of the following is true about packages?
a) Classes in the same package can access each other. b) The inherited class should be in the same package as the parent class. c) Package name a.b implies, package b is inherits from package a. d) Package access is next to private access in being restrictive.
-
Predict the output of the given code:
{geshibot language="java"}public class Test { private static String msg = "HCL "; static{ Thread t = new Thread(new Runnable(){ public void run(){ msg = "Technologies "; } }); t.start(); } public static void main(String[] args){ System.out.print(msg); }}{/geshibot} a) Compiles and prints HCL b) Compiles and prints Technologies c) Compiles and prints HCL Technologies d) Output can be HCL or Technologies
-
Which of the following options can be inserted at the commented line to compile the given code:
{geshibot language="c"}public class Class1 { Class1(String s){ } Class1() { } } class Class2 extends Class1{ Class2(){ } Class2(String s) {super(s);} void m1() { // insert code here } }{/geshibot} a) Class1 c1 = new Class1("HCL"){ } b) Class1 c1 = new Class2(){ }; c) Class2 c3 = new Class1(String s){}; d) Class1 c1 = new Class1(100){ };
-
What will be the result of compiling and executing the code listed below?
{geshibot language="java"} public class Finder { public static void main(String[] args){ System.out.println(X.Y.Z); }} class X{ static class Y{ static String Z ="Apple"; } static W Y = new W(); } class W{ String Z = "Orange";}{/geshibot} a) Apple b) Orange c) Compile time Error d) Runtime Exception is thrown
-
Which of the following methods defined in Thread class are static?
a) sleep() b) join() c) start() d) yield()
-
Select appropriate answers for the incomplete declaration listed below?
class A ______ B ______ C { } // line 4 a) The 1st blank should be extends and the 2nd blank should be implements. b) The 1st blank should be implements and the 2nd blank should be extends. c) B is a class and C is an interface d) B and C can be either class or interface depending upon the placement of extends or implements in the 1st or 2nd blank.
-
What should be returned at line commented "//insert here" so that code returns numbers in Fibonacci sequence?
{geshibot language="c"}#include int fib(n){ if (n
-
What will be output if you will execute following c code?
{geshibot language="c"} #i ain() { float p=1,q=2,r=-2,a; a=avg(p,(q=4,r=-12,q),r); printf("%f",a); return 0; } float avg(float x,float y,float z) { return (x+y+z)/3; }{/geshibot} a) 1.000000 b) 0.333333 c) -2.333333 d) 1
-
What is the output of the following program:
{geshibot language="c"}int main() { char a = 120, b = 140; int i; i = a + b; printf("%d", i); return 0; }{/geshibot} a) 260 b) 0 c) -1 d) 1