Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 01-11-2008, 06:09 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: May 2008
Posts: 25
Default Post Ur Java Programs


Hi friends i have started dis forum regarding interview based......
so post ur programs which u think dat s neccessary in d basis of interview.....

FACTORIAL

import java.math.BigInteger;
public class Factorial {
public static void main(String[] args) {

//-- BigInteger solution.
BigInteger n = BigInteger.ONE;
for (int i=1; i<=20; i++) {
n = n.multiply(BigInteger.valueOf(i));
System.out.println(i + "! = " + n);
}

//-- int solution (BAD IDEA BECAUSE ONLY WORKS TO 12).
int fact = 1;
for (int i=1; i<=20; i++) {
fact = fact * i;
System.out.println(i + "! = " + fact);
}
}
}


Fibonacci

public class Fibonacci {
public static long fib(int n) {
if (n <= 1) return n;
else return fib(n-1) + fib(n-2);
}

public static void main(String[] args) {
int N = Integer.parseInt(args[0]);
for (int i = 1; i <= N; i++)
System.out.println(i + ": " + fib(i));
}

}

Last edited by thinkdigit123456; 01-11-2008 at 06:10 PM. Reason: Automerged Doublepost
thinkdigit123456 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 01-11-2008, 06:19 PM   #2 (permalink)
Commander in Chief
 
QwertyManiac's Avatar
 
Join Date: Jul 2005
Posts: 6,658
Default Re: Post Ur Java Programs

I don't know about interviews but indenting code is hell necessary otherwise.
__________________
Harsh J
www.harshj.com
QwertyManiac is offline  
Old 01-11-2008, 10:47 PM   #3 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Post Ur Java Programs

Nice thread.

Indentation will work if you enclose it within [ CODE] [ /CODE] tags.

I'll have to search my collection of such snippets. Will post more soon.
Bandu is offline  
Old 05-11-2008, 08:22 PM   #4 (permalink)
CAFEBABE
 
chandru.in's Avatar
 
Join Date: Mar 2008
Location: Bangalore
Posts: 474
Default Re: Post Ur Java Programs

Trust me except for freshers' interviews, algorithms and logic matter very very little in Java interviews. What matters is understanding of OO, design patterns and popular frameworks.
__________________
Chandru

http://tuxychandru.blogspot.com
chandru.in is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want Java practise programs.... redhat Programming 2 03-04-2008 03:10 PM
Freeware Programs for Flash Editing & Java Menus Tech_Wiz QnA (read only) 4 25-01-2008 09:05 AM
URGENT-Executing JAVA programs nithinks QnA (read only) 2 11-12-2006 09:57 PM
help for editing XML property files from some java programs pawan Open Source 2 01-06-2006 04:39 PM
Problem in execution of JAVA programs g_goyal2000 QnA (read only) 5 01-09-2005 11:17 AM

 
Latest Threads
- by topgear
- by Charan

Advertisement




All times are GMT +5.5. The time now is 05:54 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2