SlideShare a Scribd company logo
1 of 9
Download to read offline
FNT Software Solutions Pvt Ltd, Bangalore


                                  Java Interview Questions
                                      (Core java, Servlets, JSP)                 Date:2012-10-19

                                                                                  Time:1:30 hrs



      1) Which four options describe the correct default values for array elements of the types
         indicated?

         1)int -> 0 2)String -> "null" 3)Dog -> null

         4)char -> 'u0000' 5)float -> 0.0f 6)boolean -> true

      2) Which will legally declare, construct, and initialize an array?


    1.   int [] myList = {"1", "2", "3"};

 2.      int [] myList = (5, 8, 2);

    3.   int myList [] [] = {4,9,7,0};

    4.   int myList [] = {4, 3, 7};
      3) Which is a reserved word in the Java programming language?
    A.    method                                    B.     native

    C.    subclasses                                D.     reference

    E.    array

      4) 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 )
       {


Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore


           System.out.println( "notB") ;
         }
         else
         {
            System.out.println( "ELSE" ) ;
         }
    }
}

    A.      If a is true and b is true then the output is "A && B"

    B.      If a is true and b is false then the output is "notB"

    C.      If a is false and b is true then the output is "ELSE"

    D.      If a is false and b is false then the output is "ELSE"

        5) public void test(int x)

{
    int odd = 1;
    if(odd) /* Line 4 */
    {
       System.out.println("odd");
    }
    else
    {
       System.out.println("even");
    }
}
Which statement is true?
    A.      Compilation fails.

    B.      "odd" will always be output.

    C.      "even" will always be output.

    D.      "odd" will be output for odd values of x, and "even" for even values.
6) . What is the output when you execute the following code?
int i = 100;
switch (i) {
case 100:
System.out.println(i);
case 200:
System.out.println(i);


Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore


case 300:
System.out.println(i);
}
A) Nothing is printed B) Compile time error
C) The values 100,100,100 printed D) Only 100 is printed


7) . What is the result of compiling the following code?
public class Test {
public static void main ( String[] args) {
int value;
value = value + 1;
System.out.println(" The value is : " + value);
}}
A) Compile and runs with no output
B) Compiles and runs printing out "The value is 1"
C) Does not compile
D) Compiles but generates run time error
8) . What will happen when you attempt to compile and run the following code?
public class MyClass {
public static void main(String args[]) {
String s1 = new String("Test One");
String s2 = new String("Test One");
if ( s1== s2 ) {
System.out.println("Both are equal");
}
Boolean b = new Boolean(true);
Boolean b1 = new Boolean(false);
if ( b.equals(b1) ) {
System.out.println("These wrappers are equal");
}}}
A) Compile time error B)Runtime error.C)No output D)These wrappers are equal
9) . What is the result of the following code?
public class MyTest {
int x = 30;
public static void main(String args[]) {
int x = 20;
MyTest ta = new MyTest();
ta.Method(x);
System.out.println("The x value is " + x);
}
void Method(int y){
int x = y * y;
}}


Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore


A)The x value is 20. B)The x value is 30. C)The x value is 400. D)The x value is 600.
10) . Which of the following places no constraints on the type of elements, order
of elements, or repetition of elements with in the collection.?
A) Collection B) collection C) Map D) Set


11) What will be the output of the program?


class PassS
{
   public static void main(String [] args)
   {
     PassS p = new PassS();
     p.start();
   }

    void start()
    {
      String s1 = "slip";
      String s2 = fix(s1);
      System.out.println(s1 + " " + s2);
    }

    String fix(String s1)
    {
      s1 = s1 + "stream";
      System.out.print(s1 + " ");
      return "stream";
    }
}

    A.   slip stream

    B.   slipstream stream

    C.   stream slip stream

    D.   slipstream slip stream


12) What will be the output of the program?


class Test
{
   public static void main(String [] args)
   {
     int x=20;



Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore


         String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
         System.out.println(sup);
    }
}

    A.      small                                     B.    tiny

    C.      huge                                      D.    Compilation fails
13) What will be the output of the program?


class Test
{
   public static void main(String [] args)
   {
     int x= 0;
     int y= 0;
     for (int z = 0; z < 5; z++)
     {
        if (( ++x > 2 ) && (++y > 2))
        {
           x++;
        }
     }
     System.out.println(x + " " + y);
   }
}

    A.      52                                        B.    53

    C.      63                                        D.    64
14) What will be the output of the program?


class Bitwise
{
   public static void main(String [] args)
   {
     int x = 11 & 9;
     int y = x ^ 3;
     System.out.println( y | 12 );
   }
}

    A.      0                                         B.    7

    C.      8                                         D.    14



Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore


15) What will be the output of the program?


class SSBool
{
   public static void main(String [] args)
   {
     boolean b1 = true;
     boolean b2 = false;
     boolean b3 = true;
     if ( b1 & b2 | b2 & b3 | b2 ) /* Line 8 */
        System.out.print("ok ");
     if ( b1 & b2 | b2 & b3 | b2 | b1 ) /*Line 10*/
        System.out.println("dokey");
   }
}

 A.     ok

 B.     dokey

 C.     ok dokey

 D.     No output is produced

 E.     Compilation error
16) What will be the output of the program?


class SC2
{
   public static void main(String [] args)
   {
     SC2 s = new SC2();
     s.start();
   }

  void start()
  {
    int a = 3;
    int b = 4;
    System.out.print(" " + 7 + 2 + " ");
    System.out.print(a + b);
    System.out.print(" " + a + b + " ");
    System.out.print(foo() + a + b + " ");
    System.out.println(a + b + foo());
  }

  String foo()


Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore


    {
         return "foo";
    }
}

    A.      9 7 7 foo 7 7foo

    B.      72 34 34 foo34 34foo

    C.      9 7 7 foo34 34foo

    D.      72 7 34 foo34 7foo
17) What will be the output of the program?


class Test
{
   static int s;
   public static void main(String [] args)
   {
      Test p = new Test();
      p.start();
      System.out.println(s);
   }

    void start()
    {
      int x = 7;
      twice(x);
      System.out.print(x + " ");
    }

    void twice(int x)
    {
      x = x*2;
      s = x;
    }
}

    A.      77                                     B.    7 14

    C.      14 0                                   D.    14 14
18) What are all the methods available in the Thread class?
1.isAlive() 2.join() 3.resume() 4.suspend() 5.stop() 6.start() 7.sleep() 8.destroy()
19) Which are keywords in Java?
a) NULL b) sizeof c) friend d) extends e) synchronized



Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore


20) The Java source code can be created in a Notepad editor.
a)True    b) False

21) Choose correct ansewrs
1. Servlet is a Java technology based Web component.
2. Servlet servlets are platform-independent
3. Servlet has run on Web server which has a containers
4. Servlets interact with Web clients via a request/response using HTTP protocol.

A.1,2,3,4 B.1,2,3 C.1,3,4 D.None
22) Which of the following are interface?
1.ServletContext
2.Servlet
3.GenericServlet
4.HttpServlet
A.1,2,3,4 B,1,2 C.1,3,4 D.1,4
23) Which of the following are class?
1.ServletContext
2.Servlet
3.GenericServlet
4.HttpServlet
A.1,2,3,4 B,1,2 C.3,4 D.1,4
24) Which of the following methods are main methods in life cycle of servlet?
1.init()
2 .service()
3.destroy()
4.srop()
5.wait()
A.1,2,3,4,5 B,1,2,3 C.3,4,5 D.1,4,5
25) init(),service() and destroy()methods are define in

1.javax.servlet.Servlet interface
2.javax.servlet.ServletHttp class
3.javax.servlet.ServletRequest interface

4.javax.servlet.ServletResponse interface

A.1,2,3,4,5 B,1 C.3,4,5 D.1,4,5
26) Int init() ,.service() and destroy() methods which methods are call only once at life cycle
of servlets
1.init()
2.service()
3.destroy()
A.1,2,3 B,1,3 C.2 D.None
27) Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?
 A.     Type 1

 B.     Type 2



Java Interview Questions
FNT Software Solutions Pvt Ltd, Bangalore



 C.     Type 3

 D.     Type 4


28) JDBC stands for:
 A.     Java Database Connectivity

 B.     Java Database Components

 C.     Java Database Control

 D.     None of the above is correct
29) What are the scopes in Servelts?

   1) Page 2) request 3) response 4) session 5) application

30) What are the scopes in JSP?

   1) Page 2) request 3) response 4) session 5) application

31) What are the implicit objects in jsp?

32) What is the difference between Difference between doGet() and doPost()?

33) What is the difference between HttpServlet and GenericServlet?


34) Explain the directory structure of a web application.


35) What is a output comment?

36) What is a Hidden comment?


37) What is a Expression?

38) What is a Declaration?


39) What is a Scriptlet?

40) Explain the life-cycle mehtods in JSP?




Java Interview Questions

More Related Content

What's hot

Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Intel® Software
 
Java™ (OOP) - Chapter 5: "Methods"
Java™ (OOP) - Chapter 5: "Methods"Java™ (OOP) - Chapter 5: "Methods"
Java™ (OOP) - Chapter 5: "Methods"Gouda Mando
 
Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentalsKapish Joshi
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Nishan Barot
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 
Extracting Executable Transformations from Distilled Code Changes
Extracting Executable Transformations from Distilled Code ChangesExtracting Executable Transformations from Distilled Code Changes
Extracting Executable Transformations from Distilled Code Changesstevensreinout
 
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2Knowledge Center Computer
 
Inheritance and-polymorphism
Inheritance and-polymorphismInheritance and-polymorphism
Inheritance and-polymorphismUsama Malik
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstractionIntro C# Book
 
Easy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEEasy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEUehara Junji
 
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for EducationPythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for EducationECAM Brussels Engineering School
 
Java8 - Interfaces, evolved
Java8 - Interfaces, evolvedJava8 - Interfaces, evolved
Java8 - Interfaces, evolvedCharles Casadei
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupDror Helper
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189Mahmoud Samir Fayed
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYCMike Dirolf
 

What's hot (20)

Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*Tools and Techniques for Understanding Threading Behavior in Android*
Tools and Techniques for Understanding Threading Behavior in Android*
 
Loop
LoopLoop
Loop
 
Java™ (OOP) - Chapter 5: "Methods"
Java™ (OOP) - Chapter 5: "Methods"Java™ (OOP) - Chapter 5: "Methods"
Java™ (OOP) - Chapter 5: "Methods"
 
Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentals
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
Extracting Executable Transformations from Distilled Code Changes
Extracting Executable Transformations from Distilled Code ChangesExtracting Executable Transformations from Distilled Code Changes
Extracting Executable Transformations from Distilled Code Changes
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
 
Inheritance and-polymorphism
Inheritance and-polymorphismInheritance and-polymorphism
Inheritance and-polymorphism
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
 
Easy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVEEasy Going Groovy 2nd season on DevLOVE
Easy Going Groovy 2nd season on DevLOVE
 
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for EducationPythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
Pythia Reloaded: An Intelligent Unit Testing-Based Code Grader for Education
 
Java8 - Interfaces, evolved
Java8 - Interfaces, evolvedJava8 - Interfaces, evolved
Java8 - Interfaces, evolved
 
Core java
Core javaCore java
Core java
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189The Ring programming language version 1.6 book - Part 184 of 189
The Ring programming language version 1.6 book - Part 184 of 189
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
Inside PyMongo - MongoNYC
Inside PyMongo - MongoNYCInside PyMongo - MongoNYC
Inside PyMongo - MongoNYC
 

Viewers also liked

FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
FNT Software Solutions Pvt Ltd Placement Papers - PHP TechnologiesFNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologiesfntsofttech
 
Consejeros elegidos diversasvoces
Consejeros elegidos diversasvocesConsejeros elegidos diversasvoces
Consejeros elegidos diversasvocesalcaldiadeheliconia
 
Reporte estudiantes al 27 de marzo
Reporte estudiantes al 27 de marzoReporte estudiantes al 27 de marzo
Reporte estudiantes al 27 de marzoalcaldiadeheliconia
 
Fnt Software Solutions Pvt Ltd Company Profile
Fnt Software Solutions Pvt Ltd Company ProfileFnt Software Solutions Pvt Ltd Company Profile
Fnt Software Solutions Pvt Ltd Company Profilefntsofttech
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technologyfntsofttech
 
FNT Software Solutions Pvt Ltd Placement Papers - Android Technology
FNT Software Solutions Pvt Ltd Placement Papers - Android TechnologyFNT Software Solutions Pvt Ltd Placement Papers - Android Technology
FNT Software Solutions Pvt Ltd Placement Papers - Android Technologyfntsofttech
 
Flow chart pdf
Flow chart pdfFlow chart pdf
Flow chart pdfEmmaTen
 
FNT Software Solutions Placement Papers - Android
FNT Software Solutions Placement Papers - AndroidFNT Software Solutions Placement Papers - Android
FNT Software Solutions Placement Papers - Androidfntsofttech
 
Fnt software company profile
Fnt software company profileFnt software company profile
Fnt software company profilefntsofttech
 

Viewers also liked (19)

FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
FNT Software Solutions Pvt Ltd Placement Papers - PHP TechnologiesFNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
FNT Software Solutions Pvt Ltd Placement Papers - PHP Technologies
 
Consejeros elegidos diversasvoces
Consejeros elegidos diversasvocesConsejeros elegidos diversasvoces
Consejeros elegidos diversasvoces
 
Informe climatico no. 153
Informe climatico no. 153Informe climatico no. 153
Informe climatico no. 153
 
Informe climatico n 146
Informe climatico n 146Informe climatico n 146
Informe climatico n 146
 
Inf. climatico 293
Inf. climatico 293Inf. climatico 293
Inf. climatico 293
 
Informe del Clima.
Informe del Clima.Informe del Clima.
Informe del Clima.
 
Inf. climatico no. 138
Inf. climatico no. 138Inf. climatico no. 138
Inf. climatico no. 138
 
Informe climatico JULIO
Informe climatico JULIOInforme climatico JULIO
Informe climatico JULIO
 
Reporte estudiantes al 27 de marzo
Reporte estudiantes al 27 de marzoReporte estudiantes al 27 de marzo
Reporte estudiantes al 27 de marzo
 
Informe del clima noviembre 19
Informe del clima noviembre 19Informe del clima noviembre 19
Informe del clima noviembre 19
 
Fnt Software Solutions Pvt Ltd Company Profile
Fnt Software Solutions Pvt Ltd Company ProfileFnt Software Solutions Pvt Ltd Company Profile
Fnt Software Solutions Pvt Ltd Company Profile
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
 
Inf. climmatico no. 279
Inf. climmatico no. 279Inf. climmatico no. 279
Inf. climmatico no. 279
 
Inf. climático no. 237
Inf. climático no. 237Inf. climático no. 237
Inf. climático no. 237
 
11 e.o.t acuerdo 019 00(2)
11 e.o.t acuerdo 019 00(2)11 e.o.t acuerdo 019 00(2)
11 e.o.t acuerdo 019 00(2)
 
FNT Software Solutions Pvt Ltd Placement Papers - Android Technology
FNT Software Solutions Pvt Ltd Placement Papers - Android TechnologyFNT Software Solutions Pvt Ltd Placement Papers - Android Technology
FNT Software Solutions Pvt Ltd Placement Papers - Android Technology
 
Flow chart pdf
Flow chart pdfFlow chart pdf
Flow chart pdf
 
FNT Software Solutions Placement Papers - Android
FNT Software Solutions Placement Papers - AndroidFNT Software Solutions Placement Papers - Android
FNT Software Solutions Placement Papers - Android
 
Fnt software company profile
Fnt software company profileFnt software company profile
Fnt software company profile
 

Similar to Fnt software solutions placement paper

Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and AnswersRumman Ansari
 
1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professionalIsabella789
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaanwalia Shaan
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operatorsHarleen Sodhi
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...MaruMengesha
 
Data structures and algorithms unit i
Data structures and algorithms unit iData structures and algorithms unit i
Data structures and algorithms unit isonalisraisoni
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friendGabriel Daty
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friendGabriel Daty
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friendGabriel Daty
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friendGabriel Daty
 

Similar to Fnt software solutions placement paper (20)

sample_midterm.pdf
sample_midterm.pdfsample_midterm.pdf
sample_midterm.pdf
 
Core java
Core javaCore java
Core java
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
 
FSOFT - Test Java Exam
FSOFT - Test Java ExamFSOFT - Test Java Exam
FSOFT - Test Java Exam
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
 
1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional1z0 851 exam-java standard edition 6 programmer certified professional
1z0 851 exam-java standard edition 6 programmer certified professional
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
 
Wap to implement bitwise operators
Wap to implement bitwise operatorsWap to implement bitwise operators
Wap to implement bitwise operators
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
 
Java puzzles
Java puzzlesJava puzzles
Java puzzles
 
Data structures and algorithms unit i
Data structures and algorithms unit iData structures and algorithms unit i
Data structures and algorithms unit i
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
UNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptxUNIT 2 LOOP CONTROL.pptx
UNIT 2 LOOP CONTROL.pptx
 
Java Basics - Part1
Java Basics - Part1Java Basics - Part1
Java Basics - Part1
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friend
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friend
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friend
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friend
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 

Fnt software solutions placement paper

  • 1. FNT Software Solutions Pvt Ltd, Bangalore Java Interview Questions (Core java, Servlets, JSP) Date:2012-10-19 Time:1:30 hrs 1) Which four options describe the correct default values for array elements of the types indicated? 1)int -> 0 2)String -> "null" 3)Dog -> null 4)char -> 'u0000' 5)float -> 0.0f 6)boolean -> true 2) Which will legally declare, construct, and initialize an array? 1. int [] myList = {"1", "2", "3"}; 2. int [] myList = (5, 8, 2); 3. int myList [] [] = {4,9,7,0}; 4. int myList [] = {4, 3, 7}; 3) Which is a reserved word in the Java programming language? A. method B. native C. subclasses D. reference E. array 4) 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 ) { Java Interview Questions
  • 2. FNT Software Solutions Pvt Ltd, Bangalore System.out.println( "notB") ; } else { System.out.println( "ELSE" ) ; } } } A. If a is true and b is true then the output is "A && B" B. If a is true and b is false then the output is "notB" C. If a is false and b is true then the output is "ELSE" D. If a is false and b is false then the output is "ELSE" 5) public void test(int x) { int odd = 1; if(odd) /* Line 4 */ { System.out.println("odd"); } else { System.out.println("even"); } } Which statement is true? A. Compilation fails. B. "odd" will always be output. C. "even" will always be output. D. "odd" will be output for odd values of x, and "even" for even values. 6) . What is the output when you execute the following code? int i = 100; switch (i) { case 100: System.out.println(i); case 200: System.out.println(i); Java Interview Questions
  • 3. FNT Software Solutions Pvt Ltd, Bangalore case 300: System.out.println(i); } A) Nothing is printed B) Compile time error C) The values 100,100,100 printed D) Only 100 is printed 7) . What is the result of compiling the following code? public class Test { public static void main ( String[] args) { int value; value = value + 1; System.out.println(" The value is : " + value); }} A) Compile and runs with no output B) Compiles and runs printing out "The value is 1" C) Does not compile D) Compiles but generates run time error 8) . What will happen when you attempt to compile and run the following code? public class MyClass { public static void main(String args[]) { String s1 = new String("Test One"); String s2 = new String("Test One"); if ( s1== s2 ) { System.out.println("Both are equal"); } Boolean b = new Boolean(true); Boolean b1 = new Boolean(false); if ( b.equals(b1) ) { System.out.println("These wrappers are equal"); }}} A) Compile time error B)Runtime error.C)No output D)These wrappers are equal 9) . What is the result of the following code? public class MyTest { int x = 30; public static void main(String args[]) { int x = 20; MyTest ta = new MyTest(); ta.Method(x); System.out.println("The x value is " + x); } void Method(int y){ int x = y * y; }} Java Interview Questions
  • 4. FNT Software Solutions Pvt Ltd, Bangalore A)The x value is 20. B)The x value is 30. C)The x value is 400. D)The x value is 600. 10) . Which of the following places no constraints on the type of elements, order of elements, or repetition of elements with in the collection.? A) Collection B) collection C) Map D) Set 11) What will be the output of the program? class PassS { public static void main(String [] args) { PassS p = new PassS(); p.start(); } void start() { String s1 = "slip"; String s2 = fix(s1); System.out.println(s1 + " " + s2); } String fix(String s1) { s1 = s1 + "stream"; System.out.print(s1 + " "); return "stream"; } } A. slip stream B. slipstream stream C. stream slip stream D. slipstream slip stream 12) What will be the output of the program? class Test { public static void main(String [] args) { int x=20; Java Interview Questions
  • 5. FNT Software Solutions Pvt Ltd, Bangalore String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge"; System.out.println(sup); } } A. small B. tiny C. huge D. Compilation fails 13) What will be the output of the program? class Test { public static void main(String [] args) { int x= 0; int y= 0; for (int z = 0; z < 5; z++) { if (( ++x > 2 ) && (++y > 2)) { x++; } } System.out.println(x + " " + y); } } A. 52 B. 53 C. 63 D. 64 14) What will be the output of the program? class Bitwise { public static void main(String [] args) { int x = 11 & 9; int y = x ^ 3; System.out.println( y | 12 ); } } A. 0 B. 7 C. 8 D. 14 Java Interview Questions
  • 6. FNT Software Solutions Pvt Ltd, Bangalore 15) What will be the output of the program? class SSBool { public static void main(String [] args) { boolean b1 = true; boolean b2 = false; boolean b3 = true; if ( b1 & b2 | b2 & b3 | b2 ) /* Line 8 */ System.out.print("ok "); if ( b1 & b2 | b2 & b3 | b2 | b1 ) /*Line 10*/ System.out.println("dokey"); } } A. ok B. dokey C. ok dokey D. No output is produced E. Compilation error 16) What will be the output of the program? class SC2 { public static void main(String [] args) { SC2 s = new SC2(); s.start(); } void start() { int a = 3; int b = 4; System.out.print(" " + 7 + 2 + " "); System.out.print(a + b); System.out.print(" " + a + b + " "); System.out.print(foo() + a + b + " "); System.out.println(a + b + foo()); } String foo() Java Interview Questions
  • 7. FNT Software Solutions Pvt Ltd, Bangalore { return "foo"; } } A. 9 7 7 foo 7 7foo B. 72 34 34 foo34 34foo C. 9 7 7 foo34 34foo D. 72 7 34 foo34 7foo 17) What will be the output of the program? class Test { static int s; public static void main(String [] args) { Test p = new Test(); p.start(); System.out.println(s); } void start() { int x = 7; twice(x); System.out.print(x + " "); } void twice(int x) { x = x*2; s = x; } } A. 77 B. 7 14 C. 14 0 D. 14 14 18) What are all the methods available in the Thread class? 1.isAlive() 2.join() 3.resume() 4.suspend() 5.stop() 6.start() 7.sleep() 8.destroy() 19) Which are keywords in Java? a) NULL b) sizeof c) friend d) extends e) synchronized Java Interview Questions
  • 8. FNT Software Solutions Pvt Ltd, Bangalore 20) The Java source code can be created in a Notepad editor. a)True b) False 21) Choose correct ansewrs 1. Servlet is a Java technology based Web component. 2. Servlet servlets are platform-independent 3. Servlet has run on Web server which has a containers 4. Servlets interact with Web clients via a request/response using HTTP protocol. A.1,2,3,4 B.1,2,3 C.1,3,4 D.None 22) Which of the following are interface? 1.ServletContext 2.Servlet 3.GenericServlet 4.HttpServlet A.1,2,3,4 B,1,2 C.1,3,4 D.1,4 23) Which of the following are class? 1.ServletContext 2.Servlet 3.GenericServlet 4.HttpServlet A.1,2,3,4 B,1,2 C.3,4 D.1,4 24) Which of the following methods are main methods in life cycle of servlet? 1.init() 2 .service() 3.destroy() 4.srop() 5.wait() A.1,2,3,4,5 B,1,2,3 C.3,4,5 D.1,4,5 25) init(),service() and destroy()methods are define in 1.javax.servlet.Servlet interface 2.javax.servlet.ServletHttp class 3.javax.servlet.ServletRequest interface 4.javax.servlet.ServletResponse interface A.1,2,3,4,5 B,1 C.3,4,5 D.1,4,5 26) Int init() ,.service() and destroy() methods which methods are call only once at life cycle of servlets 1.init() 2.service() 3.destroy() A.1,2,3 B,1,3 C.2 D.None 27) Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge? A. Type 1 B. Type 2 Java Interview Questions
  • 9. FNT Software Solutions Pvt Ltd, Bangalore C. Type 3 D. Type 4 28) JDBC stands for: A. Java Database Connectivity B. Java Database Components C. Java Database Control D. None of the above is correct 29) What are the scopes in Servelts? 1) Page 2) request 3) response 4) session 5) application 30) What are the scopes in JSP? 1) Page 2) request 3) response 4) session 5) application 31) What are the implicit objects in jsp? 32) What is the difference between Difference between doGet() and doPost()? 33) What is the difference between HttpServlet and GenericServlet? 34) Explain the directory structure of a web application. 35) What is a output comment? 36) What is a Hidden comment? 37) What is a Expression? 38) What is a Declaration? 39) What is a Scriptlet? 40) Explain the life-cycle mehtods in JSP? Java Interview Questions