Posts

Showing posts with the label Answers

Database | SQL | PL- SQL Interview Questions

Write the complete query for Fetching the data from tables. select           column1, column2 . .  from           table_name where         <condition> group by   <columns> having <conditions> order by     <columns> Write the SQL for finding the second highest value. mysql> select * from employee; +---------+--------+ | name    |  salary | +---------+--------+ | Dhiraj   |   1000 | | Dhiraj   |   1000 | | Kunal    |   2000 | | Aryan    |   3000 | +---------+--------+ mysql> select * from employee emp where 2=(select count(distinct salary) from employee where emp.salary>=salary); +-------+--------+ | name  | salary | +-------+--------+ | Kunal |   2000 | +-------+--------+ Write the code to find the duplicate records in a ...

Java Interview Uncommon Questions With Answers

How to detect a loop in LinkedList? Traverse the list one by one and keep putting the node addresses in a HashTable. At any point if NULL is reached then return false and if next of the current node point to any of the previously stored nodes in HashTable then return true. What is SOLID Principle? S ingle-responsibility principle A  class  should only have a single responsibility, that is, only changes to one part of the software's specification should be able to affect the specification of the class. O pen–closed principle "Software entities ... should be open for extension, but closed for modification." L iskov substitution principle "Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program."  I nterface segregation principle "Many client-specific interfaces are better than one general-purpose interface. D ependency inversion principle One should "depend upon abstractio...

Java Coding Interview Questions with Answers

Write the java code to check prime  numbers. import java.util.Scanner; public class Prime1 { public static void main(String[] args ) { Scanner sc = new Scanner(System. in ); System. out .print( "Enter the number:" ); int number = sc .nextInt(); sc .close(); boolean flag = false ; for ( int i =2; i <= number /2; i ++){ if ( number % i ==0){ flag = true ; break ; } } if ( number <2 || flag ){ System. out .println( "Not Prime" ); } else if (! flag ){ System. out .println( "Prime Number" ); } } } Output Screen: Enter the number: 23 Prime Number Second Approach**************** import java.util.Scanner; import java.lang.Math; public class Prime2 { public static void main(String[] args ) { Scanner sc = new Scanner(System. in ); System. out .print( "Enter the number:" ); int number = sc .nextInt(); ...

Core Java Interview Question's Answers - 1

How to write java documentation comment? /** *  java statement *  java statement  */ What is JDK,  JRE,  JVM and JIT? JVM JVM stands for java virtual machine. It's basic functionality is to convert the byte code to machine code. Due to jvm and byte code java is platform independent. JRE JRE stands for java runtime environment.  It contains libraries like networking, language fundamentals, threading, IO, Date and Time, JDBC, Security, Collections, Math, Reflections. It is super set of  of jvm and hence it contains  libraries and jvm as well. It provides an environment to run the java code at run-time. JDK JDK stands for java development kit. It is a complete package which includes each and everything required for java application development. JDK contains tools for java application development like java interpreter, javac compiler , Javadoc documentation tool, jar tools for jar file executi...

Core Java Interview Question's Answers - 2

   What is overloading? The process of writing multiple methods with the same name in a class is known as Method Overloading . Here parameter list must be different in terms of Number or Order or Type of parameter( NOT ). Method name and parameter list together is known as Method Signature so in short we can say in case of Overloading Method Signature must be different.  Method Signature does not include Return type of method so Return type can be anything. Method Overloading is also known as Early Binding or Compile Time Polymorphism or Static Polymorphism . It is known as Early Binding because from the invocation statement which actual version of methods will be invoked, this binding is made earlier the execution of program by  the compiler. It is known as Compile Time Polymorphism because Compiler is making decision during the Compilation process about which exact methods. What is overriding? If we are not okay with the m...