Permutation & Combinations – Aptitude Questions with Answers This blog explains about Permutation & Combinations – Aptitude Questions with Answers and is given below : From a group of 7 men and 6 women, five persons are to be selected to form a committee so that at least 3 men are there on the committee. In how many ways can it be done? A 564 B 645 C 735 D 756 E None of these Answer: Option D Explanation: We may have (3 men and 2 women) or (4 men and 1 woman) or (5 men only). Required number of ways = (7C3 x 6C2) + (7C4 x 6C1) + (7C5) = 7 x 6 x 5 x 6 x 5 + (7C3 x 6C1) + (7C2) 3 x 2 x 1 2 x 1 = 525 + 7 x 6 x 5 x 6 + 7 x 6 3 x 2 x 1 2 x 1 = (525 + 210 + 21) = 756. 2. A box contains 2 white balls, 3 black balls and 4 red balls. In how many ways can 3 balls be drawn from the box, if at least one black ball is to be included in the draw? A 32 B 48 C 64 D 96 E None of these Answer: Option C Explanation: We may have(1 black and 2 non-black) or (2 black and 1 non-black) or (3 black). Required number of ways = (3C1 x 6C2) + (3C2 x 6C1) + (3C3) = 3 x 6 x 5 + 3 x 2 x 6 + 1 2 x 1 2 x 1 = (45 + 18 + 1) = 64. 3 . How many 4-letter […]

## RYTWAYS Fresher Interview Questions with Answers – Part 4

RYTWAYS Fresher Interview Questions with Answers – Part 4 This blog explains about RYTWAYS Fresher Interview Questions with Answers – Part 4 and is below : 1. Write a C program to check whether a number if Armstrong or not Check Armstrong Number of n digits #include <stdio.h> #include <math.h>int main() { int number, originalNumber, remainder, result = 0, n = 0 ; printf(“Enter an integer: “); scanf(“%d”, &number); originalNumber = number; while (originalNumber != 0) { originalNumber /= 10; ++n; } originalNumber = number; while (originalNumber != 0) { remainder = originalNumber%10; result += pow(remainder, n); originalNumber /= 10; } if(result == number) printf(“%d is an Armstrong number.”, number); else printf(“%d is not an Armstrong number.”, number); return 0; } Output Enter an integer: 1634 1634 is an Armstrong number. 2 . Write a C program to check whether a number is odd or even An even number is an integer that is exactly divisible by 2. Example: 0, 8, -24 An odd number is an integer that is not exactly divisible by 2. Example: 1, 7, -11, 15 Example #1: Program to Check Even or Odd #include <stdio.h> int main() { int number; printf(“Enter an integer: “); scanf(“%d”, &number); // True if the number is perfectly divisible by 2 if(number % 2 == 0) printf(“%d is even.”, number); else printf(“%d is odd.”, number); return 0; } Output Enter an integer: -7 -7 is odd. In the program, integer entered by the user is stored in variable number. Then, whether the number is perfectly divisible by 2 or not is checked using modulus operator. If the number is perfectly divisible by 2, test expression number%2 == 0 evaluates to 1 (true) and the number is […]

## RYTWAYS Fresher Interview Questions with Answers – Part 3

RYTWAYS Fresher Interview Questions with Answers – Part 3 This blog explains about RYTWAYS Fresher Interview Questions with Answers – Part 3 and is given below : We have already discussed about some questions in the previous part 1 & 2 11. Write a Java program to transpose a matrix . Java Program to transpose matrix Converting rows of a matrix into columns and columns of a matrix into row is called transpose of a matrix. Let’s see a simple example to transpose a matrix of 3 rows and 3 columns. publicclass MatrixTransposeExample{ publicstatic void main(String args[]){ //creating a matrix intoriginal[][]={{1,3,4},{2,4,3},{3,4,5}}; //creating another matrix to store transpose of a matrix inttranspose[][]=new int[3][3]; //3 rows and 3 columns //Code to transpose a matrix for(inti=0;i<3;i++){ for(intj=0;j<3;j++){ transpose[i][j]=original[j][i]; } } out.println(“Printing Matrix without transpose:”); for(inti=0;i<3;i++){ for(intj=0;j<3;j++){ out.print(original[i][j]+” “); } out.println();//new line } out.println(“Printing Matrix After Transpose:”); for(inti=0;i<3;i++){ for(intj=0;j<3;j++){ out.print(transpose[i][j]+” “); } out.println();//new line } }} Output: Printing Matrix without transpose:1 3 4 2 4 3 3 4 5 Printing Matrix After Transpose:1 2 3 3 4 4 4 3 5 12 . Write a Java program to swap two numbers without using temporary variable . Write a program to swap or exchange two numbers without using any temporary or third variable to swap. Code: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 package com.java2novice.algos; public class MySwapingTwoNumbers { public static void main(String a[]){ int x = 10; int y = 20; System.out.println(“Before swap:”); System.out.println(“x value: “+x); System.out.println(“y value: “+y); x = x+y; y=x-y; x=x-y; System.out.println(“After swap:”); System.out.println(“x value: “+x); System.out.println(“y value: “+y); } } Output: Before swap: x value: 10 y value: 20 After swap: x value: 20 y value: 10 13 . Write a Java program to print the source code . public class SourcePrint { private static final […]

## RYTWAYS Fresher Interview Questions with Answers – Part 2

RYTWAYS Fresher Interview Questions with Answers – Part 2 This blog explains about RYTWAYS Fresher Interview Questions with Answers – Part 2 and is below : We have already discussed some questions in our previous blog RYTWAYS Fresher Interview Questions with Answers – Part 1 6 . Write a Java program to swap two bits without using any variable . // C program to swap bits in an intger #include<stdio.h> // This function swaps bit at positions p1 and p2 in an integer n int swapBits(unsigned int n, unsigned int p1, unsigned int p2) { /* Move p1’th to rightmost side */ unsigned int bit1 = (n >> p1) & 1; /* Move p2’th to rightmost side */ unsigned int bit2 = (n >> p2) & 1; /* XOR the two bits */ unsigned int x = (bit1 ^ bit2); /* Put the xor bit back to their original positions */ x = (x << p1) | (x << p2); /* XOR ‘x’ with the original number so that the two sets are swapped */ unsigned int result = n ^ x; } /* Drier program to test above function*/ int main() { int res = swapBits(28, 0, 3); printf(“Result = %d “, res); return 0; } Output: Result = 21 7 . Write a java program to swap two strings using a temporary variable . // Java program to swap two strings without using a temporary // variable. import java.util.*; class Swap { public static void main(String args[]) { // Declare two strings String a = “Hello”; String b = “World”; // Print String before swapping System.out.println(“Strings before swap: a = ” + a + ” […]

## RYTWAYS Fresher Interview Questions with Answers – Part 1

RYTWAYS Fresher Interview Questions with Answers – Part 1 This blog explains about RYTWAYS Fresher Interview Questions with Answers – Part 1 and is given below : 1 . Write a Prime Number Program in Java Prime number in Java: Prime number is a number that is greater than 1 and divided by 1 or itself only. In other words, prime numbers can’t be divided by other numbers than itself or 1. For example 2, 3, 5, 7, 11, 13, 17…. are the prime numbers. In this java program, we will take a number variable and check whether the number is prime or not. publicclass PrimeExample{ public static void main(String args[]){ int i,m=0,flag=0; int n=3;//it is the number to be checked m=n/2; if(n==0||n==1){ out.println(n+” is not prime number”); }else{ for(i=2;i<=m;i++){ if(n%i==0){ out.println(n+” is not prime number”); flag=1; break; } } if(flag==0) { System.out.println(n+” is prime number”); } }//end of else } } Output: 3 is prime number 2. Write a java program for Factorial using recursion . Factorial Program using recursion in java Let’s see the factorial program in java using recursion. classFactorialExample2{ static int factorial(int n){ if (n == 0) return 1; else return(n * factorial(n-1)); } public static void main(String args[]){ int i,fact=1; int number=4;//It is the number to calculate factorial fact = factorial(number); out.println(“Factorial of “+number+” is: “+fact); } } Output: Factorial of 4 is: 24 3 . Write a java program to check whether the given number is palindrome or not In this java program, we will get a number variable and check whether number is palindrome or not. classPalindromeExample{ public static void main(String args[]){ int r,sum=0,temp; int n=454;//It is the number variable to be checked for palindrome temp=n; while(n>0){ r=n%10; //getting remainder sum=(sum*10)+r; n=n/10; } if(temp==sum) out.println(“palindrome number “); else out.println(“not palindrome”); } } Output: palindrome number 4 . Write a java program for Armstrong number . Armstrong Number in Java Let’s write a java program to check whether the given number is armstrong number or not. Armstrong Number in Java: A positive number is called armstrong number if it is equal to the sum of cubes of its digits for example 0, 1, 153, 370, 371, 407 […]

## Time & Work – Aptitude Interview Questions with Answers

Time & Work – Aptitude Interview Questions with Answers This blog explains about Time & Work – Aptitude Interview Questions with Answers and is given below : 1 . X can do a piece of work in 40 days. He works at it for 8 days and then Y finished it in 16 days. How long will they together take to complete the work? A 13 1 days 3 B 15 days C 20 days D 26 days Answer: Option A Explanation: Work done by X in 8 days = 1 x 8 = 1 . 40 5 Remaining work = 1 – 1 = 4 . 5 5 Now, 4 work is done by Y in 16 days. 5 Whole work will be done by Y in 16 x 5 = 20 days. 4 X’s 1 day’s work = 1 , Y’s 1 day’s work = 1 . 40 20 (X + Y)’s 1 day’s work = 1 + 1 = 3 . 40 20 40 Hence, X and Y will together complete the work in 40 = 13 1 days. 3 3 2 . A can finish a work in 18 days and B can do the same work in 15 days. B worked for 10 days and left the job. In how many days, A alone can finish the remaining work? A 5 B 5 1 2 C 6 D 8 Answer: Option C Explanation: B’s 10 day’s work = 1 x 10 = 2 . 15 3 Remaining work = 1 – 2 = 1 . 3 3 Now, 1 work […]

## Logical Reasoning – Aptitude Interview Questions with Answers

Logical Reasoning – Aptitude Interview Questions with Answers This blog explains about Logical Reasoning – Aptitude Interview Questions with Answers and is given below : A. Introducing a girl, a boy said, “She is the daughter of the mother of the daughter of my aunt.” How is the girl related to the boy? i) Cousin ii) Niece iii) Daughter iv) Aunt Explanation: Break the given sentence at is. Resolving from the last, Daughter of my aunt – cousin Mother of my cousin – aunt Daughter of my aunt – cousin. So, answer is cousin. B.1 A family consists of 6 members P, Q , R, X, Y, Z. 2. Q is the son of R but R is not mother of Q. 3. P and R are married couple. 4. Y is the brother of R, X is the daughter of P. 5. Z is the brother of P. Questions: 1. Who is the brother in law of R? 2. How many female members are there in the family? 3. How is Q related to X? 4. How is Y related to P? Diagram: Z(Wife’s brother) – P(Wife) = R(Husband) – Y (Husband’s brother) Q(Son) – X(Daughter) Explanation : i) P and R are married ii) P is the mother of Q iii) Q is the son of R and R is the father iv) Q and X are siblings Answers: 1. Brother in law means wife’s brother i.e. Z 2. Two female members are there […]

## Profit or Loss – Aptitude Interview Questions with Answers

Profit or Loss – Aptitude Interview Questions with Answers This blog explains about Profit or Loss – Aptitude Interview Questions with Answers and is given below : 100 oranges are bought at the rate of Rs. 350 and sold at the rate of Rs. 48 per dozen. The percentage of profit or loss is: A 14 2 % gain 7 B 15% gain C 14 2 % loss 7 D 15 % loss Answer: Option A Explanation: C.P. of 1 orange = Rs. 350 = Rs. 3.50 100 S.P. of 1 orange = Rs. 48 = Rs. 4 12 Gain% = 0.50 x 100 % = 100 % = 14 2 % 3.50 7 7 2 . A trader mixes 26 kg of rice at Rs. 20 per kg with 30 kg of rice of other variety at Rs. 36 per kg and sells the mixture at Rs. 30 per kg. His profit percent is: A. No profit, no loss B. 5% C. 8% D. 10% Answer: Option B Explanation: C.P. of 56 kg rice = Rs. (26 x 20 + 30 x 36) = Rs. (520 + 1080) = Rs. 1600. S.P. of 56 kg rice = Rs. (56 x 30) = Rs. 1680. Gain = 80 x 100 % = 5%. 1600 3 . On selling 17 balls at Rs. 720, there is a loss equal to the cost price of 5 balls. The cost price of a ball is: A. Rs. 45 B. Rs. 60 C Rs. 55 Answer: Option B Explanation: (C.P. of 17 balls) – (S.P. of 17 balls) = (C.P. of 5 balls) C.P. of 12 balls = S.P. of 17 balls = Rs.720. C.P. of 1 ball = Rs. 720 […]

## First Soft Technologies – Fresher Interview Questions with Answers

First Soft Technologies – Fresher Interview Questions with Answers This blog explains about First Soft Technologies – Fresher Interview Questions with Answers and is explained below : 1 . Difference between throw and throws in Java There are many differences between throw and throws keywords. A list of differences between throw and throws are given below: Throw Throws 1) Java throw keyword is used to explicitly throw an exception. Java throws keyword is used to declare an exception. 2) Checked exception cannot be propagated using throw only. Checked exception can be propagated with throws. 3) Throw is followed by an instance. Throws is followed by class. 4) Throw is used within the method. Throws is used with the method signature. 5) You cannot throw multiple exceptions. You can declare multiple exceptions e.g. public void method()throws IOException,SQLException. 2. Base class of exception Catching base and derived classes as exceptions Exception Handling – catching base and derived classes as exceptions: If both base and derived classes are caught as exceptions then catch block of derived class must appear before the base class. If we put base class first then the derived class catch block will never be reached. For example, following C++ code prints “Caught Base Exception” filter_none edit play_arrow brightness_4 #include<iostream> using namespace std; class Base {}; class Derived: public Base {}; int main() { Derived d; // some other stuff try { // Some monitored code throw d; } catch(Base b) { cout<<“Caught Base Exception”; } catch(Derived d) { //This catch block is NEVER executed cout<<“Caught Derived Exception”; } getchar(); return 0; } 3. Explain briefly about jdbc ? JDBC Driver is a software component that enables java application to interact with the database. […]