Thursday, February 15, 2018

Top 10 Frequently Asked Core Java Interview Questions for Java Developer

Java is leading programming language in market still as well and as the language is famous for enterprise level of development , Most of the company looks for great java developer who have a strong basic core java understanding.




Below are some of the frequently asked questions for fresher level of java developer.

           1)    Which of the following  are valid java identifiers? (choose all apply)
a.    A$B
b.    _hello
c.    false
d.    Java.util
e.    Public
f.     19_abc
           2)    Which of the following are true ? (choose all apply)
a.    short myPet =5;
b.    int myNumber = 5.6;
c.    String theString =”Scruffy”
d.    myPet.length();
e.    myNumber.length();
f.     theString.length();
                                          i.    Line a generate a compiler error
                                         ii.    Line b generate a compiler error
                                        iii.    Line c generate a compiler error
                                       iv.    Line d generate a compiler error
                                        v.    Line e generate a compiler error
                                       vi.    Line f generate a compiler error
                                      vii.    The Code compiles as is.

          3)    What is the output of the following program ?
public class WaterTank {
      
       private String brand;
       private boolean empty;
      
       public static void main(String[] args) {
              WaterTank waterTank = new WaterTank();
              System.out.println("Empty "+ waterTank.empty);
              System.out.println("Brand "+waterTank.brand);
       }

}
a.    Line 6 generates a compiler error.
b.    Line 7 generates a compiler error
c.    There is no output
d.    Empty = false , Brand = null 
e.    Empty = false , Brand =
f.     Empty = null , Brand = null

          4)    Which of the following are legal entry point methods that can be run from the command line?               (Choose all that apply)
a.    Private static void main(String[] args)
b.    Public static final main (String[] args)
c.    Public void main (String[] args)
d.    Public static void test (String[] args)
e.    Public static void main(String [] args) 
f.     Public static main(String [] args)
g.    None of the above

          5)    Given the following classes , what is the maximum number of imports that can be removed and have the code still compile ?
Package company; public class Employee{}
Package company;
Import java.lang.*;
Import java.lang.System;
Import company.employee;
Import company.*;
Public class Company{
Public void print(Employee employee){
System.out.println(employee);}}
a)    0
b)    1
c)    2
d)    3
e)   
f)     Does not compile     

            6)    Which of the following are true?
a.    A local variable of type boolean defaults to null
b.    A local variable of type float defaults to 0
c.    A local variable of type Object defaults to null
d.    A local variable of type boolean defaults to false
e.    A local variable of type boolean defaults to true
f.     A local variable of type boolean defaults to 0.0
g.    None of the above   

            7)    Given the following class which of the following line of code can replace INSERT CODE HERE to make the code compile? (Choose all that apply)
Public class Price{
Public void admission(){
INSERT CODE HERE
System.out.println(amount);
}}
a)    Int amount = 9L;
b)    Int amout = 0b101; 
c)    Int amount = 0xE;
d)    Double amount = 0xE;
e)    Double amount = 1_2_.0_0;
f)     Int amount =1_2_;
g)    None of the above;

           8)    Which of the following are true statements ?
a.    Java allows operator overloading.
b.    Java code compiled on windows can run on linux 
c.    Java has pointers to specific locations in memory
d.    Java is a procedural language
e.    Java is an object oriented language 
f.     Java is a functional programming language

          9)     will the below code compile ?
public class JavaBasics {
       @SuppressWarnings("unused")
       public static void main(String[] args) {
              System.out.println("before");
              http ://www.google.com
                     System.out.println("after");
       }
}


           10)     What will be the output of the below program ?
public class JavaBasics {


public static void main(String[] args) {
System.out.println(A.Y.Z);
}
}
class A{
static class Y{
static String Z ="White";
}

static C Y = new C();


}

class C{
String Z="Black";
}






Now give some Thought on the above question and then see the answers after you finished with your answers otherwise it will not help you 

ANS 
  1.  a,b,e
  2.  ii ,iv,v
  3. d
  4. e
  5. e
  6. g
  7. b,c,d
  8. b,e
  9. yes it will , as http: will become label and  // will be comment 
  10. Black

If you guys are not able to understand the answer reason , let us a comment will be happy to help 
if you like the set of questions please share it with your friends 




0 comments:

Post a Comment