Przejdź do głównej zawartości

Learning by doing - Java - 50+ Interview Questions for Programmers

Learning by doing - Java - 50+ Interview Questions for Programmers



50+ Interview questions for 50+ days ? We will see ;) Risky resolution but method "learning by doing" is great!!

First are coming questions regarding Arrays:
  1. How do you find the missing number in a given integer array of 1 to 100? (solution)
  2. How do you find the duplicate number on a given integer array? (solution)
  3. How do you find the largest and smallest number in an unsorted integer array? (solution)
  4. How do you find all pairs of an integer array whose sum is equal to a given number? (solution)
  5. How do you find duplicate numbers in an array if it contains multiple duplicates? (solution)
  6. How are duplicates removed from a given array in Java? (solution)
  7. How is an integer array sorted in place using the quicksort algorithm? (solution)
  8. How do you remove duplicates from an array in place? (solution)
  9. How do you reverse an array in place in Java? (solution)
  10. How are duplicates removed from an array without using any library? (solution)

Komentarze

Popularne posty z tego bloga

Stored Procedures - JDBC Java SQL

Stored Procedures: group of SQL statements that perform a particular task  Normally created by DBA Can have any combination of input, output, and input/output parameters Benefits: Performance  - compiled once but executable more times Productivity and Ease of Use  - avoid redundant code, extend SQL Database functionality  Scalability   Maintainability Interoperability Replication Security To call stored procedure from Java The JDBC API provides the CallableStatement CallableStatement myCall = myConn.prepareCall("{ call some_stored_procedure() }"); ... myCall.execute(); JDBC API parameter types IN default INOUT OUT Stored Procedure can return result sets EXAMPLE: Created stored procedure on MySQL side - NAME:  increase_salaries_for_department DELIMITER $$ DROP PROCEDURE IF EXISTS ` increase_salaries_for_department `$$ CREATE DEFINER=`student`@`localhost` PROCEDURE `increase_salaries_for_departme...

Java - variables , data types

Data Types Data types in Java are classified in to types: Primitive - which include Integer, Character, Boolean and Floating Point Non-primitive - which includes Classes, Interfaces and Arrays Integer : byte 1 byte short 2 bytes int 4 bytes long 8 bytes Floating Point : number + fractional parts  float double Character : stores character Boolean : hold true false value Variables  Instance Variables (non-Static Fields) -  Objects store their individual states in “non-static fields”, that is, fields declared without the static keyword. Class Variables - Static Fields - any field with static modifier says that there is only one copy of this variable in existence static int myClassVariable = 6;  Local Variables - a method stores it's temporary state of local variables int count=0; Parameters - variables which will be passed to the methods of a class

Inserting Data into SQL Database with Java

Inserting Data into SQL Database with Java Java Documentation - Processing SQL statements with JDBC  Process: Get connection to database Create a statement Execute SQL query import java.sql.*; /**  *  * @author www.luv2code.com  *  */ public class JdbcTest { public static void main(String[] args) throws SQLException { Connection myConn = null; Statement myStmt = null; ResultSet myRs = null; String dbUrl = "jdbc:mysql://localhost:3306/demo ?autoReconnect=true&useSSL=false "; String user = "root"; String pass = "Sasanka01"; try { // 1. Get a connection to database myConn = DriverManager.getConnection(dbUrl, user, pass); System.out.println("Database connection successfully created"); // 2. Create a statement myStmt = myConn.createStatement(); int rowsAffected = myStmt.executeUpdate(                          "...