Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Technical Interview Questions and Answers :: Java

    31 / 62


    Difference between StringBuffer and StringBuilder
    Answer:

    StringBuffer:




    1. StringBuffer is less efficient than StringBuilder.

    2. StringBuffer is synchronized i.e. thread safe. It means two threads can't call the methods of StringBuffer simultaneously.



    StringBuilder:




    1. StringBuilder is more efficient than StringBuffer.

    2. StringBuilder is non-synchronized i.e. not thread safe. It means two threads can call the methods of StringBuilder simultaneously.

    Please Login First :

    32 / 62

    Why doesn't Java support multiple inheritance?
    Answer:

    Java doesn't supports multiple inheritence because it causes ambiguity.

    Please Login First :

    33 / 62

    Write a JDBC program to retrieve student details?
    Answer:

    import java.sql.*;


    public class stuinfo{


    public static void main(String ar[]){


    try[


    class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


    Connection con=DriverManager.getConnection("Jdbc:Odbc:stu");


    Statement st=con.createStatement();


    ResultSet rs=st.excecuteQuery("select * from studin");


    while(rs.next()){


    String name=rs.getString(1);


    String rollno=rs.getString(2);


    int m1=rs.getInt(3);


    int m2=rs.getInt(4);


    int m3=rs.getInt(5);


    String dept=rs.getString(6);


    int year=rs.getInt(7);


    System.out.ptintln("Name:" name);


    System.out.ptintln("Roll No.:" rollno);


    System.out.ptintln("Marks1 :" m1);


    System.out.ptintln("Marks2 :" m2);


    System.out.ptintln("Marks3 :" m3);


    System.out.ptintln("Department :" dept);


    System.out.ptintln("Year :" year);


    }


    }catch(Exception e){System.out.println ("Exception" e);}


    }


    }

    Please Login First :

    34 / 62

    How you implement https in JSP?
    Answer:

    No Discussion on this question yet!

    Please Login First :

    35 / 62

    What are collections in java?
    Answer:

    A collection is an object that can hold references to other objects. The collection interfaces declare the operations that can be performed on each type ofcollection. The classes and interfaces of thecollections framework are in package java.util.

    Please Login First :

    36 / 62

    What are the exceptions in java?
    Answer:

    An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally.

    Please Login First :

    37 / 62

    What are the types of classes in java?
    Answer:

    No Discussion on this question yet!

    Please Login First :

    38 / 62

    What are the various concepts of java?
    Answer:

    various concept of java
    1.abstraction
    2.pollymorphisum
    3.inheritance
    4.encapsulation
    5.object
    6.class

    Please Login First :

    39 / 62

    How many ways to create object in Java?
    Answer:

    There are 5 ways to create an object in java.

    1. using new keyword

    2. using Object class clone() method

    3. using deserialization readObject()

    Please Login First :

    40 / 62

    What is the difference between final variable and constant in Java?
    Answer:

    .Final variable

    Please Login First :