Saturday, November 26, 2011

Java Problem Set 2

Posted by on Saturday, November 26, 2011
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


Wednesday, November 23, 2011

Code 2 Learn One year completion

Posted by on Wednesday, November 23, 2011
Today Code 2 Learn Completed one year.. And in this 1 year, it has seen some incredible ups, here are stats :

Code 2 Learn Website
Pageviews : 67,5000

Code 2 Learn Alexa :
India Ranking : 51,000 ( 900,000 )
World Ranking : 931,772 (initially : 5,000,000)

Code 2 Learn Facebook Page : 400+ fans.. 


Saturday, November 19, 2011

Java Graphics Tutorial - 1

Posted by on Saturday, November 19, 2011
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.



Java Certification (O1Z0-851) : uCertify

Posted by on Saturday, November 19, 2011
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'.

Friday, November 18, 2011

Java Tutorial : Identifiers, Keywords and Types

Posted by on Friday, November 18, 2011
Identifiers :

In Java programming language, an identifier is a name given to a variable, class or method. Identifiers start with a letter, underscore(_) or dollar sign ($). The following characters can be digits. Identifiers are case sensitive and have no maximum length.

Wednesday, November 16, 2011

Java Tutorial : Exceptions in Java

Posted by on Wednesday, November 16, 2011
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.

Monday, November 14, 2011

Static Keyword in Java

Posted by on Monday, November 14, 2011
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

Posted by on Monday, November 14, 2011

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.


Sunday, November 13, 2011

H1 Tags in SEO

Posted by on Sunday, November 13, 2011
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

Posted by on Sunday, November 13, 2011

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);


Friday, November 11, 2011

5 Easy Ways to get Traffic from Facebook

Posted by on Friday, November 11, 2011
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

Posted by on Friday, November 11, 2011
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;

 }

Thursday, November 10, 2011

Problem Set Java

Posted by on Thursday, November 10, 2011
 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);
    }
}

Wednesday, November 9, 2011

Problem No.1

Posted by on Wednesday, November 9, 2011
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);
}


Friday, November 4, 2011

Reading and Writing File in Java

Posted by on Friday, November 4, 2011
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)

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

Posted by on Friday, November 4, 2011

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

Posted by on Friday, November 4, 2011
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.

Thursday, November 3, 2011

Java Tutorial : What is a Class?

Posted by on Thursday, November 3, 2011
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.


Tuesday, November 1, 2011

OOPs Concept : Polymorphism

Posted by on Tuesday, November 1, 2011
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.


Any java object that can pass more than on IS-A test is considered to be polymorphic. In Java, all java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.


It is important to know that the only possible way to access an object is through a reference variable. A reference variable can be of only one type. Once declared the type of a reference variable cannot be changed.

© 2010 Code 2 Learn