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 .
|
||||||
|
||||||
|
|
13 . Write a Java program to print the source code .
public class SourcePrint {
private static final long serialVersionUID = 1L;
public void test(){
System.out.println(“Hi I’m test”);
}
public static void main(String[] args) {
new SourcePrint().test();
}
}
14 . Write a Java program to print Hello without using semicolon .
C Program to print “hello” without semicolon
We can print “hello” or “hello world” or anything else in C without using semicolon. There are various ways to do so:
- Using if
- Using switch
-
Using loop etc.
Program 1: Using if statement
Let’s see a simple c example to print “hello world” using if statement and without using semicolon.
- #include<stdio.h>
- int main()
- {
- if(printf(“hello world”)){}
- return0;
- }
Output:
hello world
REFERENCES :
https://payilagam.com/blogs/rytways-fresher-interview-questions-with-answers-part-1/
https://payilagam.com/blogs/rytways-fresher-interview-questions-with-answers-part-2/
https://www.javatpoint.com/java-program-to-transpose-matrix
http://www.java2novice.com/java-interview-programs/swap-two-numbers/
https://www.quora.com/How-do-I-print-the-source-code-of-a-program-as-its-output-in-Java
https://www.javatpoint.com/c-program-to-print-hello-without-semicolon
Final Thoughts:
In conclusion, preparing with RYTWAYS Fresher Interview Questions with Answers from Payilagam can significantly boost your confidence and readiness. By practicing these questions and understanding the model answers, you can approach your interview with clarity, stay calm under pressure, and increase your chances of success.