Close
Close

Practice questions on Let's program

Level 1

1.
Write a program to get the following output.
Hey there,
I am data!
class Ans{
  public static void main(String[] args){
    System.out.println("Hey there,\nI am data!");
  }
}

2.
Write a program to print
*
**
***
****
on screen.
class Ans{
  public static void main(String[] args){
    System.out.println("*\n**\n***\n****");
  }
}

3.
Print the following pattern on the screen
*****
 *** 
  *  
 *** 
*****
class Ans{
  public static void main(String[] args){
    System.out.println("*****\n *** \n  *  \n *** \n*****");
  }
}

4.
Write a program to print the sum of the numbers 2, 4 and 5.
class Ans{
  public static void main(String[] args){
    System.out.println(2+4+5);
  }
}

5.
Write a program to print the difference and product of the numbers 45 and 32.
class Ans{
  public static void main(String[] args){
    System.out.println(45-32);
    System.out.println(45*32);
  }
}

Level 2

Level 3

Ask Yours
Post Yours