Skip to content

Commit

Permalink
Fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
kurianbenoy committed Jun 12, 2018
2 parents cd6d1c7 + e754610 commit 3547890
Show file tree
Hide file tree
Showing 395 changed files with 183,356 additions and 54 deletions.
32 changes: 32 additions & 0 deletions Abstract Keyword/AbstractExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// a abstract class
abstract class H {
int x;

/* abstract */ int y; // variables cannot be abstract

/* abstract */ H () {x=1;} // constructor cannot be abstract

void triple (int n) {x=x*3;}; // a normal method

static int triple2 (int n) {return n*3;}; // a static method in abstract class is ok.
abstract void triple3 (); // abstract method. Note: no definition.

// static abstract void triple3 (int n); // abstract static cannot be combined
int returnMe () {return x;}
}

// H1 extends (inherits) H. When a class extends a abstract class,
// it is said to “implement” the abstract class.
class H1 extends H {
void triple3 () {x=x*3+1;} // must be defined, else compiler makes a complaint.
//Also, all return type and parameter must agree with the parent class.
}

public class AbstractExample {
public static void main(String[] args) {
// H xx = new H(); // abstract class cannot be instantiated
H1 myO = new H1(); // abstract class cannot be instantiated
myO.triple3();
System.out.println(myO.returnMe());
}
}
13 changes: 13 additions & 0 deletions Abstract Keyword/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## The “abstract” Keyword

1. The keyword abstract can be used on class declaration. For example abstract MyClassX (…);.
1. The keyword abstract can be used on method declaration. For example abstract int f (…);.
1. When a class is declared abstract, it cannot be instantiated.
1. When a method is declared abstract, it cannot have definition.
1. Only abstract classes can have abstract methods. Abstract class does not necessarily require its methods to be all abstract.

## Purpose of Abstract Classes

The purpose of abstract class is to serve purely as a parent of classes. (that is, solely for the purpose of extension (inheritance) by other classes.)

The difference between abstract class and “normal” class is that, the abstract class's methods cannot have any definition.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ First off, thanks for taking the time to contribute!
* The aim of the repository is mainly to help out newcomers to Java programming. Kindly keep that in
mind and add necessary comments in your source code.

* Make the program user friendly. The user shouln't be left with doubts while running a program.
* Make the program user friendly. The user shouln't be left with doubts while running a program.
For example : While requiring an user input , add a print statement along with it describing what
the user should input.

* Include your program within the appropriate package. For example all GUI's are included within
"guiprojects" package.
Expand All @@ -34,8 +36,6 @@ There are various channels, on which you can ask questions:

* PM in Linkedin : https://www.linkedin.com/in/yedhin1998

* Contact me via WhatsApp (intended for close friends)

## Code Style

Refer to this [Code Convetion](http://www.oracle.com/technetwork/java/codeconvtoc-136057.html) while writing your source files.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions Data Types And Operators/CommonDataTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package operators;
public class CommonDataTypes {
/**
* This program demonstrates common variable type usage and
* how to format output of variables.
*/
public static void main(String[] args) {
String studentName = "Bette Itall";
int age = 22;
double gpa = 3.75;
boolean isFemale = true;
System.out.printf("%s is %d years old. %s has a %4.3f gpa.\n",
studentName,
age,
(isFemale ? "She" : "He"),
gpa);
}
}
File renamed without changes.
33 changes: 33 additions & 0 deletions Data Types And Operators/OnePlusTwoEqualsTwelve.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package operators;

import java.util.Scanner;

public class OnePlusTwoEqualsTwelve {

public static void main(String[] args) {
// 1 + 2 equals 12? Whaaaaaaaaaaaaat??!?!?!?
String x = "1";
String y = "2";
System.out.println(x + y); // not what you expect;

String first = "Jimmy ";
String last = "Page";
System.out.println(first + last );

// so, how does one to convert string to int?
int i = Integer.parseInt(x);
int j = Integer.parseInt(y);

System.out.println(i + j);

// What about booleans?
String areYouHappy = "true";
boolean ishappy = Boolean.parseBoolean(areYouHappy);
System.out.println(ishappy);

// Or String to double?
String gpa = "3.96";
Double realgpa = Double.parseDouble(gpa);
System.out.println(realgpa - 1.0 );
}
}
5 changes: 4 additions & 1 deletion Operators/README.md → Data Types And Operators/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# The Java programming language has around 30 operators as summarized below:
## Primitive Data Types
Check out this [link](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html) to learn in detail about basic data types.

## The Java programming language has around 30 operators as summarized below:
```
Simple assignment
=
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions Data Types And Operators/UnderstandingTypeCasting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package operators;

public class UnderstandingTypeCasting {

public static void main(String[] args) {
// This demo will help explain type casting.
int x = 20;
int y = 15;
int i = x / y; // int / int == int
double d1 = x / y; // int / int == int then cast to double
// implicit type cast
double d2 = x / (y * 1.0); // int * double == double; int / double = double
// explicit type cast
double d3 = x / (double)y; // int / double = double

System.out.println(i);
System.out.println(d1);
System.out.println(d2);
System.out.println(d3);
}
}
4 changes: 2 additions & 2 deletions EventHandling/sum_2nos.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package guiprojects;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
Expand All @@ -15,7 +16,7 @@ public class sum_2nos extends Applet implements ActionListener

public void init()
{
// t1.setForeground(Color = Red);
//t1.setForeground(Color = Red);
add(l1);
add(t1);
add(l2);
Expand All @@ -36,4 +37,3 @@ public void actionPerformed(ActionEvent e)
}
}
}

50 changes: 50 additions & 0 deletions JDBCTemplate/JdbcBeg.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

import java.sql.*;
/********************
Contributed by leo
->make sure that you have JDBC Driver install.
->You should have a SQL server Running.
************************/
public class JdbcBeg implements Runnable{
//Threads are just used to make Server timings
public void run() {
System.out.print("Connecting to SQL DB waiting For Connection ");
for (int i = 0; i < 5; i++) {
try {
Thread.sleep(1000);
System.out.print(".");
} catch (InterruptedException e) {
System.out.println("Error while threading .");
}
}
System.out.println("\nYou are connected to SQL DB");

}
public static void main(String[] args) {
Thread thread=new Thread(new JdbcBeg());
thread.start();
try{
Thread.sleep(5000);
thread.join();
}catch (InterruptedException e){
System.out.println("Something wrong while threading.");
}

try {
//Connection is obtained using GET method. Replace the url,username,password with yours.
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306", "root", "nopass1234");
Statement statement = connection.createStatement();
statement.executeUpdate("use employee");//Use your update statements instead of mine.
ResultSet resultSet = statement.executeQuery("select * from livesin");//Use your select queries here
//Result is stored as a ResultSet object
while (resultSet.next()) {
System.out.println();
System.out.println(resultSet.getString("pname") + " " + resultSet.getString("street") + " " + resultSet.getString("city") + " ");
//Replace the column label to columns used in the table
}

} catch (SQLException sqlException) {
System.out.println("Error occurred while processing");
}
}
}
21 changes: 21 additions & 0 deletions JDBCTemplate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Requirements

* Set up MySql
* [in Windows](https://www.roseindia.net/mysql/installing-mysql-on-windows10.shtml)
* [in most common Linux distros](https://dev.mysql.com/doc/refman/8.0/en/linux-installation.html)

**in Arch Linux setting up both MySql and JDBC can be found [here](https://wiki.archlinux.org/index.php/JDBC_and_MySQL)**

* Set up JDBC
* [in Windows](https://blogs.msdn.microsoft.com/brian_swan/2011/03/02/getting-started-with-the-sql-server-jdbc-driver/)
* [in Linux](https://stackoverflow.com/questions/5307048/where-do-i-install-a-jdbc-driver-on-ubuntu)

## Creating your own Database in MySql (optional)

After completing the installations , follow this [link](https://www.liquidweb.com/kb/create-a-mysql-database-on-linux-via-command-line/) and create a database of your own.
Do this if you want to learn working with MySql. Else make use of the already created DB in the given example(s).

## Usage

Its important to note that , when , say you're in Arch Linux, then your default vendor is mariadb , thus in the program you would have to replace "mysql" with "mariadb".
Rest of the execution as same as what had been done with other programs , compile and run `JdbcBeg.java`
Loading

0 comments on commit 3547890

Please sign in to comment.