Frequently Asked Programming Interview Questions and Answers
Hint: Select the down arrow available on the top right on the download page to get the file [Save to your Desktop and/ Smart Phone].
Frequently Asked Programming Interview Questions and Answers
=== Write a profram to read a number and display its no.of digits in it ====
package sample.programs;
import java.util.Scanner;
public class Lab1 {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("Enter the number:");
int a =sc.nextInt();
System.out.println("Number is:"+a);
String str =String.valueOf(a);
System.out.println("No.of digits :"+str.length());
}
}
=== Write a program to read a number and display its factorial ===
package sample.programs;
public class Lab3 {
public static void main(String[] args) {
Hello h = new Hello();
long b= h.Factorial(5);
System.out.println(b);
}
}
class Hello{
public long Factorial(int a){
if(a==0)
return 1;
else
return a*Factorial(a-1);
}}
==== write a program to read number and display its fibonacci series and Nth fibonacci series number==
package sample.programs;
public class Lab5 {
public static void main(String[] args) {
int a=5;
int arr[] = new int[a];
for (int i = 2; i < arr.length; i++) {
arr[0]=0;
arr[1]=1;
arr[i]=arr[i-1]+arr[i-2];
}
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
System.out.println("Nth fibonacci number:"+arr[a-1]);
}
}
=== Write a program to read number and display its individual sum ===
package sample.programs;
public class Lab4 {
public static void main(String[] args) {
int n = 1234;int rem,sum=0;
while(n!=0){
rem=n%10;
sum=sum+rem;
n=n/10;
}
System.out.println(sum);
}
}
=== Write a program to read a number to display it==
package sample.programs;
public class Lab6 {
public static void main(String[] args) {
int i = 235;
String str = String.valueOf(i);
int a=str.length();
System.out.println("Given number :");
for (int j = 0; j < str.length(); j++) {
System.out.println(str.charAt(j));
}
System.out.println("Reverse of given number:");
for (int k =str.length()-1 ; k >=0; k--) {
System.out.println(str.charAt(k));
}
}
}
Learn More | PDFs | Like | Follow
Updates: Don’t miss, what you want? So kindly, 1. Like our Facebook, 2. Subscribe by E-mail, 3. Follow our Google+, 4. Twitter 5. YouTube, 6. Download our Toolbar, 7. Install our App and 8. Others.
Help: If you have any suggestions, requests and problems, please comment below or ask us here.
Alerts: Dear viewer, “Hard work never fails”. Along with hard work include smart work for your goal. Your hard work and our smart work, guarantee success. To get in touch with you, we have created a WhatsApp Group named “Question Answer Explanation”. Kindly send a message to +91-7893356131 as “add to Question Answer Explanation" to add you to this group.
Help: If you have any suggestions, requests and problems, please comment below or ask us here.
Alerts: Dear viewer, “Hard work never fails”. Along with hard work include smart work for your goal. Your hard work and our smart work, guarantee success. To get in touch with you, we have created a WhatsApp Group named “Question Answer Explanation”. Kindly send a message to +91-7893356131 as “add to Question Answer Explanation" to add you to this group.
Encourage us: Please don’t forget to G+1 and/ Like and/ Share and/ Recommend… thank you and all the best / best of luck for your bright future.
Our motto: Serve poor and needy whole heartedly – Nareddula Rajeev Reddy (NRR) and his team.
Comments
Post a Comment
* Dear viewer, ask us what you want..?