Posts

Write program in JavaScript to print Fibonacci series up to 15 Observations

Fibonacci series in  JavaScript var limit = prompt("Enter the limit 'n' to generate the Fibonacci  series:", " "); var f1=0; var f2=1; document.write("The limit entered to generate the Fibonacci  series is: ",limit, "<br/>"); document.write("The Fibonacci  series is: "); document.write("",f1," "); document.write("",f2," ");   var i,f3; for(i=2; i<limit; i++) { f3=f1+f2; document.write("",f3,", "); f1=f2; f2=f3; } OutPut : The limit entered to generate the Fibonacci series is: 20 The Fibonacci series : 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 The limit entered to generate the Fibonacci series is: 15 The Fibonacci series : 0 1 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377,

Palindrome program in Java using BufferedReader

import java.io.*; class Test { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("\nEnter a String : "); String str = br.readLine(); String rev = ""; int n = str.length(); for(int i=n-1 ; i>=0 ; i--) { rev = rev + str.charAt(i); } if(str.equals(rev)) System.out.println("\nGiven string is a palindrome"); else System.out.println("\nGiven string is not a palindrome"); } } Output 1 Enter a String : ABCDDCBA Given string is a palindrome Output 2 Enter a String : abcdabcd Given string is not a palindrome

Java Script Notes

Image
Overview In JavaScript, almost everything is an object or acts like an object.When a web page is loaded, the browser creates a HTML Document Object Model of the page. The HTML DOM is a standard for how to get, change, add, or delete HTML elements. The HTML DOM model is constructed as a tree of Objects: It defines: The HTML elements as objects The properties of all HTML elements The methods to access all HTML elements The events for all HTML elements With the object model, JavaScript gets all the power it needs to create a dynamic HTML: -JavaScript can change all the HTML elements/attributes/CSS styles in the page -JavaScript can remove existing HTML elements and attributes -JavaScript can add new HTML elements and attributes -JavaScript can react to all existing HTML events in the page -JavaScript can create new HTML events in the page The HTML DOM Tree of Objects Properties and Methods : An object has properties and methodes to work on these properties. methods are also considered as ...

Groovy Notes

 Groovy is a great mix of dynamic flavor, while still  being able to use types. It is one of few languages  that sport optional typing, that is, the flexibility  to provide type information if we want to and leave  type information aside when we don't want to. Closure in Groovy is a block of code that can be assigned to  a reference or passed around just like any other variable.  The concept is known as lambda in many other languages,  including Java 8 or function pointers. 1.) Hello World program   def cl1 = {      println "hello world!" } cl1.call() it prints the following: hello world! 2.) As closures are like methods, they can also accept parameters: example 1: def cl2 = { n ->     println "value of param : $n" } cl2.call(101) It prints the following: value of param : 101 example 2: 3.times(cl2) It prints the following: value of param : 0 value of param : 1 value of param : 2 We can also inline the block a...

How to manage deadlines ?

Are you scared of Deadlines ? many people do. many meet their deadlines by working late , putting themselves under tremendous pressure.and in the process loose their peace of mind, ignore their family and so on. and if you miss it then you feel bad about it and you leave a bad impression on your team and can potentially impact the delivery of the project. So, why should one have deadlines ? one, it will make you focused and you can devote 100% only on that particular work and can easily postpone other work till you finish that. First thing to know is who is setting up those deadlines ?  is it you ?  your boss ? or a third party ? do you have nay say in it ?  make sure you have the final say in it otherwise you will end up stressing yourself. And,  other thing keep in mind is that not every project or work can have a dead line. if you do that then you are putting yourself under unnecessary pressure. deadlines should be set for a project or work where it has to...

OOPS: Decomposition and Abstraction

When we write a a program and if the the code is expected to be less than few hundred of lines then we can afford to write a monolithic program but if the number of lines increase it becomes difficult  to maintain that program or adding new features to that program.  so how to handle this ? In order to write a program for a problem , the problem should be broken into multiple smaller problems and then each smaller problem should be solved  and make sure that solving all such smaller problem solves the actual , bigger problem. the process of breaking a problem into multiple smaller problem efficiently involves Decomposition and Abstraction. Definitions Decomposition- How to decompose large programming problems into small ones is called decomposition Abstraction - Abstraction is a way to do decomposition productively by changing the level of detail to be considered. In each iteration the irrelevant information can be removed. The process of abstraction can be seen as an app...
Generics Array Java does not permit the construction of generic array. Suppose, for example, that we want to design a class that has an array field public class Table<AnyType> { private AnyType[] contents = new AnyType[5]; ... } It's hard to understand, but this is illegal! A workaround is to construct an array of objects with a type-cast: public class Table<AnyType> { private AnyType[] stack = (AnyType[]) new Object[5]; ... } source - http://www.cs.cmu.edu/~adamchik/15-121/lectures/Collections/collections.html