11/26/11

Java Problem Set 2

Write a function which calculates the sum of even Fibonacci numbers.

public static void main(String args[]) {
    for(int i=1;i<22;i++)
        System.out.print(sumofEvenFibonacci(i) + " ");
}

public static long sumofEvenFibonacci(int n) {
    // add your code here.
    return sum;
}

prints

0 0 2 2 2 10 10 10 44 44 44 188 188 188 798 798 798 3382 3382 3382 14328



11/22/11

11/19/11

Java Graphics Tutorial - 1

As we all know that we can make games with the help of java libraries that provide us with the graphics needed for making them. So today I will be starting a very new section on Java Graphics. I had earlier made posts on How to make an income tax calculator.

To start with here are some prerequisites :

-You should have fair idea about java syntax because I am not going to teach that. Graphic Design College is a good educational resource in learning more about Java. 
-You should have Eclipse downloaded (anyone will do i.e Indigo, Galileo, Ganymede etc.)
- You should Download acm.jar file and include it into your project as an external jar file.




11/18/11

Java Certification (O1Z0-851) : uCertify

In today's world if you are an IT professional so you are bound to have certain certification to increase your value in the IT industry. So today I am going to review an uCertify Certification course for Java (O1Z0-851)

Before we proceed lets have an idea about uCertify. uCertify is one of the best in providing certifications of different languages, software ranging from Microsoft, Oracle, Cisco etc. It gives materials which has an in-depth information of the topics that are there, and these training materials are called 'prepKits'.


11/16/11

Java Tutorial : Exceptions in Java

An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following:
  1. A user has entered invalid data.
  2. A file that needs to be opened cannot be found.
  3. A network connection has been lost in the middle of communications, or the JVM has run out of memory.


11/14/11

Static Keyword in Java

While you are programming you would want to use some class members independently of any object of that class. Normally a class member is accessed with the help of the object of that class. However, it is possible to create class members that can be used by itself. To create such a member, the keyword static has to precede its declaration. 


Multilingual SEO


Search Engine Optimization is very crucial for the success of any online business. With the help of SEO, you can get your website optimized in such a way that you receive good traffic inflow from your target audience.



11/12/11

H1 Tags in SEO

H1 tags are one of the most important part of SEO which is the header tag situated in body of a website. It can be termed as the most simple form of header found on a web page. Through h1 tags search engines come to know about the site content details.




Problem Set 3


The below questions are very interesting and amazing questions. So please do try it.

QUESTION 1

int a=5,*b=&a;
printf("%d",a**b);



11/11/11

5 Easy Ways to get Traffic from Facebook

This is my First Guest Post on Code 2 Learn. and my personal Blog is DailyTechTips for SEO and Wordpress Stuff.

No Doubt Facebook is the best Social Networking Site. It gets Millions of Daily Visits, so if seen from a Blogging eye, it can get tons of traffic to your Blog. Many use Facebook for Marketing and the results they reveal are too awesome. So just think to get huge traffic from Facebook.




Methods Explanation : Java Tutorial

A Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println method, for example, the system actually executes several statements in order to display a message on the console.

Now you will learn how to create your own methods with or without return values, invoke a method with or without parameters, overload methods using the same names, and apply method abstraction in the program design.

Creating a Method : 

In general, a method has the following syntax:
 modifier returnValueType methodName(list of parameters) { 

  // Method body;

 }


11/10/11

Problem Set Java

 Predict the Output  


 Question 1


class Base {
    public void Print() {
        System.out.println("Base");
    }
}
class Derived extends Base {
    public void Print() {
        System.out.println("Derived");
    }
}
class Main{
    public static void DoPrint( Base o ) {
        o.Print();
    }
    public static void main(String[] args) {
        Base x = new Base();
        Base y = new Derived();
        Derived z = new Derived();
        DoPrint(x);
        DoPrint(y);
        DoPrint(z);
    }
}


11/8/11

Problem No.1

The below program is hideously slow. CAN YOU SPOT THE REASON?

public static void main(String args[]){
      Long sum=0L;
      for ( long i=0; i < Integer.MAX_VALUE; i++){
          sum += i;
      }
      System.out.println(sum);
}



11/4/11

Reading and Writing File in Java

Java like other programming languages supports both reading and writing of files. For reading purpose we use FileReader and for writing we use FileWriter.


FileReader Class :

The FileReader class creates a Reader that you can use to read the contents of a file. Its two most commonly used constructors are shown here:

FileReader(String filePath) 
FileReader(File fileObj)


11/3/11

Public static void main(String args[]){} : Explained


public static void main(String args[]){

}

Now lets understand why do we write the above statement, the way it is written above. 

Why not change it?

Before we move to the topic make sure you understand the Keyword Static, to learn about it here is our tutorial on Static Keyword in Java.

The public keyword is an access specifier, which allows the programmer to control the visibility of class members. When a class member is preceded by public, then that member may be accessed by code outside the class in which it is declared. (The opposite of public is private, which prevents a member from being used by code defined outside of its class.


Good Practices : Programming Tips Java

One of the Good practices while programming using Java is listed below.


Consider Static Factory Methods instead of Constructors

The normal way for a client to obtain an instance of itself is to provide a public constructor. But apart from this their is another technique which should be the part of every programmer's toolkit. A class can provide a static factory method, which is static method which returns the instance of the class.


Java Tutorial : What is a Class?

Java class is nothing but a template for object you are going to create or it’s a blue print by using this we create an object. In simple word we can say it’s a specification or a pattern which we define and every object we define will follow that pattern.


What does Java Class consist of :
  • When we create class in java the first step is keyword class and then name of the class or identifier we can say.
  • Next is class body which starts with curly braces {} and between this all things related with that class means their property and method will come here.