Friday, January 30, 2015

JAVA INHERITANCE

Java Inheritance

October 2014. About this time, I already bought an Asus computer from Fry’s because I was going to need it to study for the MCSA Configuring Windows 8.1 Exam 687. I bought it for less than a public junior college semester course.

As you might know already, unless you don’t read technical web pages, Windows 8.1 is going to be off the market soon and so will its derivate Windows 9. Microsoft is churning out Windows 10 instead.

Windows 8 could not compete with its predecessor Windows 7's likeability. Among the flaws of Windows 8 I have encountered is that the tile environment is separated from the desktop environment. For example, if you log in to a WiFi in the desktop environment, you need to log in again in the tile environment. However, it seems that this flaw might have been corrected by a Windows 8 update.

Currently, I am taking an Advanced Java class and we are studying Java inheritance. Java allows only single inheritance, but you can simulate multiple inheritance using interfaces.

Here’s a Java program that shows constructor chaining in an inheritance.

public class Bird extends Pterodactyl {
  public String toString() {
    return "I am a bird.";
  }
  public static void main(String[] args) {
    Bird bird = new Bird();
    System.out.println(bird.toString());
  }
}

class LivingThings {
  public LivingThings() {
    System.out.print("I am a living thing. ");
  }
}

class Animals extends LivingThings {
  public Animals() {
    System.out.print("I am an animal. ");
  }
}

class Dinosaurs extends Animals {
  public Dinosaurs() {
    System.out.print("I am a dinosaur. ");
  }
}

class Pterodactyl extends Dinosaurs {
  public Pterodactyl() {
    System.out.print("I am a pterodactyl. ");
  }
}

Here is the console run and output of the above program.
> run Bird
I am a living thing. I am an animal. I am a dinosaur. I am a pterodactyl. I am a bird.
>

CYK:
What keyword is use to create instances in Java?
What keyword is use to call the superclass constructor or superclass method?
What’s the new paradigm that is replacing the swing package GUI capability?

Look up in the sky! It's a bird! ...

John Sindayen

Reference:
http://java67.blogspot.com/2012/12/how-constructor-chaining-works-in-java.html

Tuesday, January 27, 2015

BRANCH & LOOP

BRANCH & LOOP

September 2014. I’ve been looking at the job requirements for programmers at this time.

A lot of the jobs required applicants to know a lot of computer languages. For example, one job requires knowing C#, Visual Basic, HTML, CSS, and SQL also. Another job would require knowing C or C++, Java, JavaScript, PHP, HTML, and SQL.

So I decided to learn at least ten computer languages, both programming and web scripting languages, along with RDBMS languages. I decided to have knowledge of these languages: Java, C, C++, C#, VB.Net, Python, JavaScript, PHP, HTML, CSS, and SQL.

In the meantime, here’s a program of the list of the syntaxes or examples of the entire programming world’s selection and loop statements. If somebody invents a new one, he or she will be instamatically famous.

class Instamatic {
  public static void main(String[] args) {
    boolean boolean_expression = true;
    String variable;
    String expression1 = "constant1";
    String expression2 = "constant2";
    String[] array = new String[100];

    if (boolean_expression) {
      //Statements
    }

    if (boolean_expression) {
      //Statements
    }
    else {
      //Statements
    }
   
    variable = boolean_expression ? expression1 : expression2;
   
    if (boolean_expression) {
      //Statements
    }
    else if (boolean_expression) {
      //Statements
    }
    else {
      //Statements
    }
   
    switch (variable) {
      case "constant1":
        //Statements
        break;
      case "constant2":
        //Statements
        break;
      default:
        //Statements
        break;
    }
   
    //Statements
    while (boolean_expression) {
      //Statements
    }
   
    //Statements
    do {
      //Statements
    } while (boolean_expression);
   
    for (int i = 0; i < 100; i++) {
      //Statements
    }
   
    for (String element : array) {
      //Statements
    }

  }
}

CYK:
How do you encapsulate a data field?
What kind of token follows the case keyword in C and C++?
What Java data type uses 4 bytes but has no precision?

Loop before you leap!

John Sindayen

References:
https://msdn.microsoft.com/en-us/library/aa292164(v=vs.71).aspx
http://www.dba-oracle.com/t_grid_rac_rdbms_language.htm
http://www.engineersblogsite.com/what-is-node-branch-and-loop-in-a-circuit.html
http://en.wikipedia.org/wiki/Significant_figures

Saturday, January 24, 2015

VARIABLE TYPE

VARIABLE TYPE FOR DATA TYPE

August 2014. About this time, a student needed some tutoring in C. I have not taken a C programming class before and I did not want to take one since C is a subset of C++. I would rather learn C by myself than pay a $300 semester course for C.

I looked at the student’s C program that was not working and tried to debug it. Since I have taken Advanced C++ already, it was not hard to decipher C’s heavy use of pointers or to debug his program. Without pointers C could not do any input and output operations at all.

The concept of variable data type started with C. This is why C is the most successful programming language ever in existence. It’s success is exemplified by all the other languages that adapted its style, particularly C++, Java, Visual Basic, and C#, and by all the popular operating systems of today that uses it, specifically Windows, Mac OS, Linux, and Unix.

Strictly speaking, JavaScript, PHP and Python does not have variable data types as defined in C, C++, C#, Java, SQL and Visual Basic programming languages. HTML and CSS has no variable data type, by definition of variable.

This is the list of primitive data types used by variables in many languages. These data types are particular to Java. All, except byte and boolean, are derived from C and C++.

This program is written in Python, for simplicity.

#Python program that prints the primitive type and their ranges.
print(" boolean range:  true to false                                          ")
print(" char range   :  all original Unicode characters including ASCII        ")
print(" byte range   :  -128 to 127                                            ")
print(" short range  :  -32768 to 32767 or +/- 32K                             ")
print(" int range    :  -2147483648 to 2147483647 or +/- 2 billion             ")
print(" long range   :  -9223372036854775808l to 9223372036854775807L          ")
print("                 or +/- 9 billion billion dollars                       ")
print(" float range  :  1.40129846432481707e-45f to 3.40282346638528860e+38F   ")
print(" double range :  4.94065645841246544e-324d to 1.79769313486231570e+308D ")

C and C++ also has signed and unsigned data types.
C# and VB also has Decimal data type and VB has Single data type.

CYK:
What Java primitive data type is not in C++?
What primitive data type cannot be cast to another data type in Java?
What does a local variable do to a global variable of the same name?

Happy data typing!

John Sindayen

References:
https://msdn.microsoft.com/en-us/library/47zceaw7.aspx
http://zetcode.com/lang/python/datatypes/
http://www.w3schools.com/js/js_datatypes.asp
http://php.net/manual/en/language.types.php
http://zetcode.com/lang/csharp/datatypes/
http://www.tutorialspoint.com/plsql/plsql_data_types.htm
http://www.tizag.com/sqlTutorial/sqlcreate.php
http://stackoverflow.com/questions/7247202/how-to-use-variable-in-css
http://www.w3.org/TR/html4/types.html
http://www.cplusplus.com/doc/tutorial/variables/

Wednesday, January 21, 2015

JAVA Date

Java Date

July 2014. About this time, summer tutoring sessions will be ending early next month and the fall semester will start also next month. I have spent all this time tutoring in the same college classroom at the same hours, I think, five days a week.

Last month also, I had to take all three of the IC3 examinations: Computing Fundamentals, Key Applications (using Word, Excel, PowerPoint, and Access), and Living Online. It was recommended that I passed them when tutoring how to use a computer and these Microsoft software.

I took one exam a week in three consecutive weeks and had only one week to study for each exam. I passed all three in the first try. So now, I can include in my resume that I have a Certiport IC3 certificate.

Now, back to the future, the Spring 2015 semester had just begun yesterday. And tomorrow, I have to start attending a classroom class in Advanced Java.

So here’s a Java program that tells you how to get a date.

import java.util.Date;
import java.util.Calendar;

class HowToGetADate {
  public static void main(String[] args) {
  Date date;
  Calendar calendar;
  calendar = Calendar.getInstance();
  calendar.set(Calendar.YEAR, 1970);
  calendar.set(Calendar.MONTH, Calendar.JANUARY);
  calendar.set(Calendar.DAY_OF_MONTH, 1);
  date = calendar.getTime();
  System.out.println(date.toString());
  }
}

CYK:
What Java data type cannot be cast into a different data type?
What Date constructor is deprecated in Java?
What Java keyword is not used?

Welcome back class!

John Sindayen

Sunday, January 18, 2015

JAVA String

Java String

June 2014. This month marked one year since I went to take that summer course in Beginning Java.

About this time, I was continuing into my next stint tutoring programming in college. The summer course was only 2 months long, and there were more students wanting to learn about Microsoft’s software, particularly Word and Excel. The students had to take their IC3 examinations and most of the students who were going to the Tutorial Lab needed some help in passing their exams.

This was the first time the college has a summer tutoring for programming. One or some of the tutees I had tutored in Microsoft’s software wrote the Tutorial Services some impressive comments that the Director asked me if I was interested in doing tutoring during the summer. Since I had nothing else to do, of course, I said yes.

For the summer tutoring sessions, I wrote a Python program as a sign-in sheet for the students going to the Tutorial Lab. It save to a file, including the current time when their name was entered in the file.

Here’s a Java program segment that illustrates how the Java String class is used. This program segment is capable of authenticating an email address and the corresponding password that are entered by the user.

    String[] emails = {"ant", "bat", "cat"};   
    String[] passwords = {"aa", "bb", "cc"};

    Scanner keyboard = new Scanner(System.in);
    System.out.print("Enter your email address: ");
    String response1 = keyboard.nextLine();
    System.out.print("Enter your password: ");
    String response2 = keyboard.nextLine();
    for (int index = 0; index < emails.length; index++) {
      if (emails[index].compareToIgnoreCase(response1) == 0) {
        if (passwords[index].equals(response2)) {
          System.out.println("You may proceed");
          break;
        }
      }
      if (index >= emails.length - 1) {
        System.out.println("Incorrect email or password");
        break;
      }
      else
        continue;
    }

CYK:
Is a Java string immutable?
What's the length of an empty string?
What data type holds single precision value?

Happy computing!

John Sindayen

Thursday, January 15, 2015

JAVAX SWING

Javax Swing Package

May 2014. The semester has ended and I received my grade in my Advanced C++ class, A. All my programs received the same top grades and took almost the same amount of time, over 24 hours for each assignment.
These hours actually include studying the new programming concepts applied in the program, because the only way to learn programming is to learn the concept and practice what you learned, almost immediately, in an actual program.
The program that probably took the most time is the program that used overloaded operators to add, subtract, multiply, and divide two fractions. The reason why it took a long time is that I also simplified the resulting fraction, even though it was not an explicit part of the requirements.
The program already met all the requirements, but I believe a fraction should be simplified. I tested the program with some test data and it worked well with these data. But when I changed a pattern to these data, I found the solution did not simplify that data. So I went to lunch and tried to work out the solution in a piece of paper, a white napkin. And I came back to write the code for the algorithm I wrote on the napkin. After a few more tweaking, all test data I’ve used before now returns the correct simplified fraction.
The next advanced programming class I will take is Advanced Java. So I have been reviewing what I learned last Summer 2013 in my first modern day programming class.
Java is now in its eight version and the Swing package is being replaced by JavaFX. JavaFX is not a package, but a platform software supported by the Java API. It has several packages used for graphical client applications.
Here is a program that uses the most common dialog boxes of the Swing package.
package John;
import javax.swing.*;
public class myClass {
  public static void main(String[] args) {
    String input = JOptionPane.showInputDialog("Please enter a floating point number:");
    double dollar = Double.parseDouble(input);
    JOptionPane.showMessageDialog(null, "You entered $" + dollar);
    System.exit(0);
  }
}
CYK:
What package does a class belong if the package name is not explicit?
What does FX mean in JavaFX?
What data type consists of constant identifiers?
Welcome to Java!
John Sindayen

Monday, January 12, 2015

SQL

SQL

April 2014. This is the last month before the end of my Advanced C++ course Spring semester.

So far, I have been able to write all my programs and complete all specifications in the requirements list of the assignments. That is always a milestone to complete a fully functional program that meets all requirements.

I have been spending this time earning a living tutoring Java, C++, Raptor, Python, and JavaScript programming, computer fundamentals, Microsoft Windows 7, Word, Excel, and PowerPoint. I can also tutor Visual Basic, C, and Microsoft Access, but no students have come by the Tutorial Lab to learn these tools.

Around this time, I have noticed that a lot of the job ads for programmers in the online postings also require a knowledge of SQL. So I decided to learn some SQL also.

SQL stands for Structured Query Language. It is the standard language to communicate with a relational database or a DBMS software. DBMS software stores data into two-dimensional tables. SQL language or a version of SQL is used to access the data in the DBMS.

SQL can be used as a stand-alone query to a DBMS and it can also be embedded in a program, like a program written in C. The SQL code can be outside a method or inside a method.

The SQL language is not a true programming language because it is not Turing complete. A Turing complete language, like Java, is able to write a solution for any problem, assuming there is a solution.

The following is an SQL code to create a table named Students.

CREATE TABLE Students
(
StudentID int,
LastName varchar(100),
FirstName varchar(100),
CourseNumber varchar(50),
CourseTitle varchar(50),
);

The following is the SQL code to insert a record in the above created table.

INSERT INTO Students (StudentID, LastName, FirstName, CourseNumber, CourseTitle)
VALUES ('Sindayen', 'John', 'CIT 230', 'Advanced Java');

This specific blog page completes all the terms enumerated in this blog’s subheading.

CYK:
What type of database model do DBMS use?
What are the two dimensions of a table?
What does an SQL code query?

Happy SQLing!

John Sindayen