0% found this document useful (0 votes)
1 views

Java Demo Session

The document contains a series of programming questions and their corresponding answers, primarily focused on Java. The questions cover various topics such as checking for odd/even numbers, string manipulations, anagrams, and calculating averages. Each question is numbered and includes specific requirements for the coding tasks.

Uploaded by

ragerspirit037
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Java Demo Session

The document contains a series of programming questions and their corresponding answers, primarily focused on Java. The questions cover various topics such as checking for odd/even numbers, string manipulations, anagrams, and calculating averages. Each question is numbered and includes specific requirements for the coding tasks.

Uploaded by

ragerspirit037
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

1.

Question
1.give a number
2.if it contains more than 2 odd numbers print “TRUE”.

3. else print “FALSE”.

Answer

import java.util.Scanner;

class HelloWorld {

public static void main(String[] args){

Scanner sc=new Scanner(System.in);

String ip=sc.nextLine();

int count=0;

char[] ch=ip.toCharArray();

for (char chr:ch){

int num=Character.getNumericValue(chr);

if(num%2==1){

count++;

if(count > 3){

System.out.println("True");

}else{

System.out.println("False");

}
2.Question
1.find the largest and smallest substring as per the value of k.
2.print the smallest and largest one, data should be String and integer for k.
3.Question
1.Check a string and it’s reverse should be same.
2.if same print “True” else “False”.

4.Question
1.Check the 2 words are anagram or not.
2. Both words are needed to be String.
3.if anagram print “True” else “False”.
5.Question
1.Convert int to string.
2. and then check if the int and String(needs to be changed) is equal or not.
3.if correct print ”Good Job” else “Wrong”.

6.Question
1.get an input in a type of String.
2.add the each and every odd numbers from the input and print it.
7.Question(Java 2)
1.give a number in a type of array format.
2.make the sum of digits for the input.
3.if the sum divides by 3 print “True” else “False”.

8.Question(Java 3)
1.give a number in an array format.

2. add only the odd numbers.

3.if sum is greater than 8 AND less then 50 print “True” else “False”.
9.Question (Java 1)(Video 10).
1.get 5 numbers in an integer format.
2.then give 2 limits.
3. we need to find average for the sum of numbers between the 2 limits.

10.Question
1.Find the number of lowercase letter in a given string.
11.Question
1.Print all the odd index character from the given string.

12.Question
1.Find the number of words in a given string or sentence.

And we also use trim() in split() line to make the array w/o any spaces.
13.Question
1.find how many even numbers in the given number.
2.if count > 2 print “True” else “False”.

14.Question
1.Reverse the words in a given String.
15.Question (OWN).
1.Reverse the words in a given string.
2. and also in the words each and every letter’s needs to be reversed.

16.Question
1.Print the every first letters of the words in the given string.
17.Question
1.give a string and a character.
2.then print a sequence characters by removing the given character from the
given word.

18.Question
1. print all the last letters of the words as a string.
19.Question
1.Find the given number is perfect number.
2.Ex… 6 , Perfect Number, How, divisors of 6 are 1,2,3. Where 1+2+3=6.
3.Ex… 8 , Not a Perfect Number, How, divisors of 8 are 1,2,4. Where 1+2+4=7.

20.Question
1.Count the number of spaces in the string.

2. we can also add Conditions like if spaces count are greater than 3 then
print ”True” else “False”.
21.Question
1.Removing the duplicates in the string.

22.Question
1.identify the number of vowels, consonants and number in the given string.
23.Question
1.Give a input string.
2.Print the string in that remove the characters when we get 1st repeated
letter .
3.Until we get 1st repeated letter we can store. If we saw a repeated letter
the break it.
24.Question
1.Give a string.
2.if the given string contains “CHN” then print the last 3 letters of the string in
reverse.

1.Give a string.
2.if the given string only starts with “CHN” then print the last 3 letters in
reverse.
25.Question.
1.Give a string.
2.print the word which has a higher length in the given string.

26.Question
1.Give two numbers as a limit.
2.with in that limit identify the sum and count of the numbers which are
divisible by 2 & 3.
35 Mark Question
1.Question:

1.Answer:
2.Question

2.Answer
3.Question
3.Answer
4.Question

4.Answer
5.Question
5.Answer
6.Question
6.Answer

You might also like