Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

JAVA STARTER PART 1

 

 GET STARTED IN CODING WITH JAVA 

JAVA DOCS : java 

JAVA DOWNLOAD : Java download

Java Learning Material : link

 

PART 001:
EI - Increment/Decrement:


import java.util.Scanner;

public class Hello {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        if (N < 10) {

            N++;

        } else {

            N--;

        }

        System.out.print(N);

    }

}

*************************************************************************

MFIB - Print Yes - Both Integers are Odd (Condition)


import java.util.Scanner;

public class Hello {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        int Y = sc.nextInt();

        if ((X%2!=0)&&(Y%2!=0)) {

            System.out.print("Yes");

        } else {

            System.out.print("No");

        }

    }

}

*************************************************************************

MFIB - Print Yes - At Least One of the Two Integers is Even (Id-10646)

Fill this in  the blanks:

A%2==0 || B%2==0

*************************************************************************

EI - Sum of Two Integers (Id-10656)


import java.util.Scanner;


public class Hello {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        int Y = sc.nextInt();

        System.out.print(X+Y);

    }

}

*************************************************************************

MFIB - Print 12


public class Hello {


    public static void main(String args[]) {

        int M = 5;

        int N= ++M + M;

        System.out.print(N);

    }

}

*************************************************************************MFIB - Yes/No - At least One of the Two Integers is Odd

Fill in the blanks:

X%2!=0 ||Y%2!=0

*************************************************************************
EI - Next Number

import java.util.Scanner;

public class Hello {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        System.out.printf("%d", N+1);

    }

}

*************************************************************************
MFIB - Print 11 and 11 (Id-10647)
Fil in the blanks:
int N=10
*************************************************************************MFIB - Half of the Number:

in first blank --> sc.nextInt()
in second blank --> N/2
*************************************************************************MFIB - Square the Integer:
in first blank --> sc.nextInt()
in second blank --> N*N
*************************************************************************

MFIB - Product of Two Integers

in first blank --> sc.nextInt();
in Second blank --> sc.nextInt();
in Third blank --> A*B
*************************************************************************

MFIB - Two Integers Equal or Not (Condition)

X==Y

*************************************************************************
MFIB - Remainder Two Integers (Id-10681)

in first blank --> int
in Second blank --> A%B
*************************************************************************

EI - Print Yes/No - At least One of the Two Integers is Even (Id-10652)

import java.util.Scanner;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        if (X % 2 == 0 || Y % 2 == 0) {
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }
    }
}
*************************************************************************
MFIB - Print Integer:
in first blank --> sc.nextInt()
*************************************************************************

MFIB - Larger Integer (Condition)

in first blank --> num1>=num2
*************************************************************************
MFIB - Multiply the Number with 2
in first blank --> sc.nextInt();
in second blank --> N*2

*************************************************************************
MFIB - At least One Even or Not (Condition)
in first blank -->X % 2 == 0 || Y % 2 == 0||Z%2==0
*************************************************************************

MFIB - Odd and Even (Condition)
in first blank --> num1%2!=0 && num2%2==0


*************************************************************************
EI - Product - Precision Two Decimal Places

import java.util.Scanner;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        float A = sc.nextFloat();
        float B = sc.nextFloat();
        System.out.printf("%.2f",A*B);
    }
}

*************************************************************************
MFIB - Accept & Print - Single Character (Id-10653)

in first blank --> sc.next().charAt(0)
*************************************************************************

EI - Print String

in the program find the word "char" and replace it with the word "String"
*************************************************************************

 MFIB - Four Integers - Product of Quotient and Remainder (Id-10663)
in first four blanks --> sc.nextInt();
in fifth blank-->(A/B)*(C%D)
*************************************************************************

MFIB - Four Integers - Quotient of Remainders
in first four blanks --> sc.nextInt();
in fifth blank-->(A%B)/(C%D)

*************************************************************************
MFIB - Four Integers - Sum of Remainders
in first four blanks --> sc.nextInt();
in fifth blank-->(A%B)+(C%D)
*************************************************************************

MFIB - Four Integers - Sum of Product and Quotient
in first four blanks --> sc.nextInt();
in fifth blank-->(C*B)+(D/A)

*************************************************************************
EI - Print skill or rack
               case 's':
                System.out.println("skill");
                break;
            default:
                System.out.println("rack");

*************************************************************************
MFIB - Four Integers - Subtraction of Remainders
in first four blanks --> sc.nextInt();
in fifth blank-->(A%B)-(C%D)
*************************************************************************

MFIB - Four Integers - Subtraction of Products
in first four blanks --> sc.nextInt();
in fifth blank-->(A*D)-(C*B)
*************************************************************************
MFIB - Four Integers - Quotient of Sum
in first four blanks --> sc.nextInt();
in fifth blank-->(A+C)/(B+D)
*************************************************************************

MFIB - Three Integers - Sum and Product
in first blank --> (C+A)*B
*************************************************************************

FIB - Print String    ID:10662

Scanner sc=new Scanner(System.in);
String a=sc.nextLine();
System.out.println(a);

*************************************************************************
 MFIB - Four Integers - Quotient - Subtractions (Id-10672)

in first four blanks --> sc.nextInt();
in fifth blank-->(A-B)/(C-D)
*************************************************************************

MFIB - Quotient Two Integers (Declaration)
in first two blanks --> sc.nextInt();
in third blank-->(A/B)
*************************************************************************

MFIB - Four Integers - Sum of Quotient and Remainder
in the blank-->(A/B)+(C%D)

*************************************************************************
MFIB - Four Integers - Product of Sum
in first four blanks --> sc.nextInt();
in fifth blank-->(A+B)*(C+D)

*************************************************************************
MFIB - Three Integers - Subtract & Multiply (Declaration) (Id-10682)
in first-->C
in second-->A
in third-->B

*************************************************************************
MFIB - Four Integers - Subtraction of Quotients (Id-10680)
in the blank-->(A/B)-(C/D)
*************************************************************************

MFIB - Four Integers - Product of Sum and Subtraction (Id-10683)
in first four blanks --> sc.nextInt();
in fifth blank-->(A+B)*(C-D)

*************************************************************************
MFIB - Three Integers - Subtract and Divide
in the blank-->(C-B)/A

*************************************************************************
MFIB - Four Integers - Sum of Products
in first four blanks --> sc.nextInt();
in fifth blank-->(A*B)+(C*D)
*************************************************************************

MFIB - Four Integers - Quotient of Sum
in first four blanks --> sc.nextInt();
in fifth blank-->(A+B)/(C+D)

*************************************************************************
 MFIB - Four Integers - Product of Difference (Id-10690)
in first four blanks --> sc.nextInt();
in fifth blank-->(A-B)*(C-D)
*************************************************************************

MFIB - Four Integers - Quotient - Subtraction and Sum

in first four blanks --> sc.nextInt();
in fifth blank-->(C-D)/(A+B)
*************************************************************************

MFIB - Next Alphabet (Id-10655)
in first blank--> sc.next().charAt(0);
in fifth blank-->ch++
*************************************************************************
MFIB - Tenth Digit Odd (Condition)
in the blank -->((num/10)%10)%2!=0

*************************************************************************
 MFIB - Absolute Difference Two Integers (Id-10684)
in the first two blanks--> sc.nextInt();
in third blank-->Math.abs(X-Y)
*************************************************************************

MFIB - Square Exists or Not (Condition)
in the blank-->
sideA==sideB && sideB==sideC &&sideC==sideD
*************************************************************************

MFIB - Previous Alphabet
in first blank--> sc.next().charAt(0);ch--
in second blank--> ch
*************************************************************************
MFIB - ASCII Value of Alphabet
in first blank--> sc.next().charAt(0);
in second blank--> (int)ch

*************************************************************************
MFIB - Print Last Character
in first blank--> sc.nextLine();
in second blank--> str.charAt(str.length()-1)

*************************************************************************
MFIB - Alphabet Position

in the blank-->(int)ch-96
*************************************************************************

MFIB - Alphabet Position in Reverse
in first blank--> sc.next().charAt(0);
in second blank--> 26-((int)ch-97)
*************************************************************************

MFIB - Two Integers Sum
in first blank--> sc.nextInt();
in second blank--> char z=sc.next().charAt(0);
in third blank-->sc.nextInt();
*************************************************************************

FIB - Three Integers - Sum and Divide:

int A,B,C;
char d,e;
A=sc.nextInt();
d=sc.next().charAt(0);
B=sc.nextInt();
e=sc.next().charAt(0);
C=sc.nextInt();
*************************************************************************
_________________END OF THE POST____________________

 

Post a Comment

Previous Post Next Post