Skip to main content

JAVA INTERVIEW QUESTIONS


JAVA INTERVIEW QUESTIONS


1.      What will be the result of attempting to compile and run the following class?
public class Assignment {
    public static void main(String[] args) {
        int a, b, c;
        b = 10;
        a = b = c = 20;
        System.out.println(a);
    }
}
  1. The code will fail to compile, since the compiler will recognize that the variable c in the assignment statement a = b = c = 20; has not been initialized.
  2. The code will fail to compile because the assignment statement a = b = c = 20; is illegal.
  3. The code will compile correctly and will display 10 when run.
  4. The code will compile correctly and will display 20 when run.

2.      Which statements are true?
a.      The result of the expression (1 + 2 + "3") would be the string "33".
b.      The result of the expression ("1" + 2 + 3) would be the string "15".
c.       The result of the expression (4 + 1.0f) would be the float value 5.
d.      The result of the expression ('a' + 1) would be the char value 'b'.

3.      What will the following program print when run?
// Filename: MyClass.java
public class MyClass {
    public static void main(String[] args) {
        B b = new B("Test");
    }
}

class A {
    A() {
       this("1", "2");
      }

    A(String s, String t) {
         this(s + t);
     }

    A(String s) {
      System.out.println(s);
     }
}

class B extends A {
    B(String s) { System.out.println(s); }

    B(String s, String t) { this(t + s + "3"); }

    B() { super("4"); };
}

Select the one correct answer.
  1. It will simply print Test.
  2. It will print Test followed by Test.
  3. It will print 123 followed by Test.
  4. It will print 12 followed by Test.

4.      Which one of these is not a legal member declaration within a class?
a.      static int a;
b.      final Object[] fudge = { null };
c.       abstract int t;
d.       native void sneeze();

5.      Which statements are true about modifiers?
a.      Fields can be declared synchronized.
b.      Non-abstract methods can be declared in abstract classes.
c.       Classes can be declared native.
d.      Abstract classes can be declared final.

6.      What is the purpose of final   variables
             
             a.      Making a constant
             b.      To hide a variable in child class
             c.       To protect from inherited classes
             d.      Making a variable of fixed memory

7.      The mother of all classes in Java
             
             a.      java.lang.Object
             b.      java.lang.Class.object
             c.       java.lang.System.Object
             d.      java.Object

8.      Java does not support

             a.      Operator overloading
             b.      Function overloading
             c.       Constructor overloading
             d.      Method overloading

9.       _________used to access the parent class members

              a.      extend
              b.      public
              c.       this
             d.      super

10.  What will be the result of attempting to compile and run the following program?
public class Polymorphism {
                     public static void main(String[] args) {
                                         A ref1 = new C();
                                           B ref2 = (B) ref1;
                                           System.out.println(ref2.f());
                     }
}
 
class A  {
                     int f() {
                     return 0;
                     }
 }
class B extends A { 
                    int f() { 
                    return 1; 
                    } 
}
class C extends B {
                     int f() { 
                    return 2; 
                    } 
}
Select the one correct answer.

a.      The program will fail to compile.
b.      The program will compile without error and print 0 when run.
c.       The program will compile without error and print 1 when run.
d.      The program will compile without error and print 2 when run.      

Popular posts from this blog

CONVERTING TORRENT FILE TO ZIP FILE

HOW TO CONVERT TORRENT FILE TO ZIP FILE 1>>click the link below  http://www.zbigz.com   2>>upload your .torrent file  3>>wait until conversion, after conversion your  file can be downloadable in .zip format.

Responsive PanelGrid in JSF Primeface

Here, we are going to learn about responsive PanelGrid in JSF Primeface component. As we know primefaces providing lots of good stuffs for JSF. In Primeface, there is a component name Panel Grid which we are going to use for our convenience. In most of the cases, PanelGrid used for making our content in a proper way. If users opens our website which we have made in jsf using panelGrid component that not in responsive manner, that could be really ugly as for as user concern, So here we are going to break it just by using Layout attribute in the panel Grid component. for exaple, < h3 >Responsive</ h3 > < p:panelGrid columns = "3" layout = "grid" >                 < h:outputText value = "Content" />      < h:outputText value = "Content" />      < h:outputText value = "Content" />      < h:outputText value = "C...

Single name in facebook

HOW TO SET SINGLE NAME IN FACEBOOK Step 1: Go to settings and select general tab. Step 2: change the default language to Bahasa indonesia. Step 3: Now go to options in firefox browser and select advance tab ,under network tab click settings Step 4: Go to  http://www.proxynova.com/proxy-server-list/country-id/ and select country as “ Indonesia ”, choose port= “ 8080 ”. Step 5: Copy any one of the proxy with port 8080 and paste that in firefox manual proxy configuration .  Step 6: Now go back to facebook tab and click change name and leave the last name tab as blank and click save , i will ask your facebook password provide it and click confirm. Step 7: Now shift to your default language.