Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views

Coding Output and Program Question

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Coding Output and Program Question

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Topic Name

Coding output and Program questions

"public class Demo{

psvm(String[] args){

try{

Sop(""1"");

int i=10/0;

catch(NullPointerException e){

Sop(""2"");

try{

Sop(""3"");

int i=20/0;

catch(ArithematicException e){

Sop(""4"");

e.printStackTrace();

"

"string s1=""Java ""

String s2="" technology ""

How Concate both string

"

"Largest palindrome substring

String=""babad""

Output-bab

Or

Output-aba

String=""abba"";
Output-bb

Diagonal matrix program

1000

0100

0010

0001

10001

01010

00100

01010

10001

"

Program for reverse string

swapping two numbers without using third variable

"string objects means pool and heap concepts, how much objects will be created from

1) String s=”amit” 2) String s=”amit” 3) String s=new string ”amit”

"

"Statement

public class A{}

public class B{}

public abstract class C {}

public abstract class D

public interface E {}

public interface F {}

which is correct from follow options

1 A a = new C();

2 C a = new C();

3 class abstract C extends A , B

4 public class A implements B extends E , F

5 public abstract class C extends D implements E , F

"

"class A{
Public string method() throws Exception {

Class B extends A{

Public string method() throws RuntimeException

"

How can u write dynamically from 1 to 10 elements without using integrator or for loops
or any types of loops

second largest no. in array

if you have emp and empdto class and we need to filter imp object with greater than
15000 salary and we need to store result int empdto list , How you will do that

Coding questions related to sting

Factorial of a number

I have text file I want to know which word occurred multiple items?

Program find prime no

Reverse string

Pattern coding question

Factorial of a number

What are the differences .between Annotations n XML configuration .integration of


SpringBoot with Restfull webservice in order to call a service of an application deployed
on the server

Reverse string

"String s=""java"";

String s1="" java"";

How many objects created?

"

"how to sort the data

(2,Programming) (3, Databases) (4,ETL) (1,Docker) (5,Cloue)


"

"String str1 = ""Hello""; String str2 = ""HELLO"";

if (str1.equals(str)2))

if (str1 == str2)

"

write the even program?

"Class A

Void M1(object o)

Class B

Void M1(string s)

Class C

PSVM (String a[])

M1(null)

O/p=?

"

"Class A

Void M1(Integer i)

Class B

Void M1(string s)

Class C

PSVM (String a[])

M1(null)

O/p=?

"

write fibboniccai series program

write duplicate occurrence of string in sentence print it's occurrence count

"Q.
111111

111122

111333

114444

155555

666666

"

“Abcdmadam” find maximum possible palindrome

8 unique balls are there. Comparable weighing machine is there. Among 8 balls, 7
weighs same and one is heavier. Find at least for how many times you will use weighing
machine to find heavier ball.

"Public static void m1 (object obj)

Public static void m1 (string str)

Main()

m1(null) what is output?

"

Write code for reverse each word in a given string?

Write code for sorting given array?

employee id,age,name sort it age wise

Reverse of array

Program to return the sum of all the elements from both the diagonals in N×N
Matrix.Matrix is a two dimensional array of int type. int[ ][ ] matrix;

String reverse program without using inbuilt methods.

java code to print repeated char for a string

String reverse without using any inbuilt/ready-made methods.

Return the sum of both the diagonals of any NxN matrix i.e. int[][].

"You've given a list of Employees.

Sort them according to their salary and age together.

3.1) Using lambda expressions

3.2) Using anonymous class

"

"Implement all the different ways to remove duplicates from a list.

like using your custom logic, Set, Stream API etc

"
"Write a method to return the square of a number without using

multiplication (*) operator or Math class or any inbuilt functionality.

The input number can be an Integer or a Float.

"

"Print numbers from 1 to 100 without using any loop or iterators or Stream.

Then modify the same program to print in reverse, from 100 to 1.

"

"Write a code to print a given number in words.

Number won't be greater than your expected LPA in Rs.

input =>> 750000

output =>> ""Seven Lac Fifty Thousand""

"

"If we have a linked list and it contains duplicate values how to remove it

And str = ""abcde"" str1 =""ahjdksbjcksjsejkop"" if all the characters of str are present
in the str1. Occurrence is not important

"

There are two string arraylist one with a,b,c,d and another with c,d,e,Write a program to
find common element in two list

write code to swap 2 string without using third variable

add element into arrylist and remove duplicates

write code for method overloading

String str=” java is Object oriented programming language”; , Write code to remove
extra space

program to reverse string without function

suppose if A1 array and A2 array check A2 is subarray of A1 or not

Program on ( 1,9,2,3,0,5,0,7,0,4,0,6) Print all non zero no first then all zero at one line

String a="manish";String b ="manish";how many object will create

wap for revrese a String

Suppose i have string name="vijay"; then how to reverse a string

How to check whether character 'c' is present in the string="vijay"

Print 3rd 4th character in string="vijay"

Prog to reverse String

replace element as "abcdef" who multple of by 3,5

Prog for Array it contain 1 to 20


replace element as "abc" who is multple of 3

replace element as "def" who is multple of5

Sum of square od odd no from array

"Parent class has 2 methods run() & walk()

child class has two overriden methdo of parent class

Each class calls its super implementation

Parent p = new Child()

p.run()

which methods will get called from which class and sequence

"

write program to check dublicate elements is afrray

write a program of array that if similar elements should be added and if all the element
are same then output shoud be 0.

"Write a program to find triplet number

fore.g// int a[]={1,2,3,4,5,7}// here 1+2 = 3 is present in the array 2+3= 5 is present
in the array 3+4=7 present

in the array but 3+5= 8 not present in array so write code for it.

"

"WAP for Find string is substring of second string or not

String s= ""meeting""

String s1=""meet""

WAP to find First non repeating character from String

"

"WAP to find Not Common From String

String s= ""nikhil"";

String s1=""nitesh"";

"

How you are going to sort array if it's containing 0,1,1,0,0,0,1,1,0

How to find middle elements of array if you don't know array size

pallindrome string programme?

if i hava 10 lakh numbers in array then how to find duplicates?


"**

**

**

**

***

4 * ( x+ 3 ) + (y + 2 ) //I have this string I want it take at runtime and i want result of
it suppose x=10 and y=20 iwant result of this expression

"

Reverse string w/o reverse method

Swap no without 3rd variable like temp

Conunt string char Palindrome

"String s=new String""java"";

String s1=""java"";

how many objects,location and refrences

"

one array based program like if 2nd array is present in 1st array in same order then
return the index of number of 1st array where 2nd array is present

"what is string intern method

String str=new string""abc"";

string s1=""abc"";

"

code for ()()=true (()=false

code for copying array using ArrayList

code for occurrences of character

code for HashMap

code for palindrome string

WAP for Sorting Salary, name, I'd of employee

"1 Code : You have total 100 peoples and each one has one number you need to check
which person is having a number which is divisible by 3 and you need to check number
by
Eg when you check 1 then next no to be check will be 5 then 11 so on

Print no which is divisible else return 0

"

"1] Count pairs with given sum in array

int arr[] ={1,3,7,5,4,2,-1}

Sum : 6

Condition: Single for loop only.

"

"3] str=""vishal"";

str.concatenate(""kawthale"");

sysout(str)

"

Find second max value from array using single for loop

"6] Count number words in given string

Ex String str = ""Hello world, I am Vishal Kawthale"";

"

MySQL query for 4th highest salary?

Java program for reverse string?

Program for max find no in array

"

Write custom exception

"

Reverse string w/o reverse method

Swap no without 3rd variable like temp

Conunt string char Palindrome

Program for counting duplicate character

Program for string character count?

Program for string reverse without using reverse method?

Program for display 4 th position array . U have to compare it with previous array
position and last max no u have to print it.

Program on matrix
Program to find duplicate in spring?

Program to find tallest boy in given program (not recalling it properly)

"Output for list l= new ArrayList();

Output of

l.add(1);

1.add(""abc"");

l.add(1.0f);

l.add(0,0);

"

"Program (a=1,b=2,c=3..z=26)

ip:-abz

op:-1+2+26

"

swapping without using 3rd variable

Replacing value with production of other value in array

swapping without using mathematical operator and without using temp

Length without for loop and length function

Print 1 to 100 without using any Loop.

Find the Second highest number from the array.{100,45,52,67,122,125}

Find the second-highest number when all are negatives.

How to remove duplicate elements in string(only logic).

palendrom number program

Show implemetation of default method programtically?

Write a program to find the numbers of occurences in string?

You have one list {1 4 2 6 7 1 8 1 1 7 0 1 } write a program to fetch all the 1 using java
8?

you have one class person in which person name age and sakary is mention as
field.Write a program to fetch the person name whose age is greater than 50?

Write a program to sort the map by value using java8.

Write a program to fetch the person name whose age is greater than 50?

Write a pojo class. write Dao layer.

How to reverse string in java

Can we use static method in interface

What will be output of sop(“test”+10+20+30);


Write query for sql, we have two tables we have to remove duplicates names as well as
count names.

How to remove duplicates from ArrayList?

"if I have one list in that list I want remove all duplicate value with real value for multiple
value

Input:[2,3,4,3,4,5,6,7,8,7]

Output:[2,5,6,8]"

Wap to calculate factorial with using recursion.

"class A{

Public static void add(){

Sop(hello);

}}

Class B extends A{

Public static void add(){

Sop(hello);

}}

B b= new B();

B.add();"

"class A {

public void read() {

System.out.println(“read in class A”);

class B extends A{

protected void read() {

System.out.println(“read in class B”);

public static void main (String[] args) {

A a1 = new B();

a1.read();

}"

"public class NewT extends Thread {

public void run (Object obj){


System.out.println(""NewT running"");

public static void main (String[] args) {

NewT thread = new NewT();

thread.start();

What will be the behaviour when you compile & run above code snippet?"

"class A {

final int i;

public static void main (String[] args) {

A a1 = new A();

a1.read();

public void read() {

System.out.println(i);

What will be the behaviour when you compile & run ?"

.2nd highest salary....

Query to fetch Top 5 highest salaries

Query to get common names from two tables

Use of "Group by " -- write a query.

"Input: Arr = { 3, 4, -7, 1, 3, 3, 1, -4 } target = 7

//Output: Subarrays with the

//given sum are { 3, 4 } { 3, 4, -7, 1, 3, 3 } { 1, 3, 3 } { 3, 3, 1 }"

etch the record from Report table and Ids are 23,25,29.( select * from report where id
in(23,25,29);

Find the number occurring odd number of times in an array

Search an element in rotated and sorted array.

Separate odd and even numbers in an array

Find the second-highest number when all are negatives.


swaping without 3rd variable

how do you reserve the number(123=321)

what is the time complexity of bubble sort algo

Write a bubble sort algo

you have 9 balls in which only 1 ball is heavyer and all others are same weight, how
many min and max time you have to take weight of balls so that you will find the hevyer
one.

"public class streamsortpublic class streamsort

public static void main(String[] args)

List<Integer> list = Arrays.asList(10, 23, -4, 0, 18);

List<Integer> sortedList =
list.stream().sorted().collect(Collectors.toList());

System.out.println(list);

System.out.println(sortedList);

o/p

[10, 23, -4, 0, 18]

[-4, 0, 10, 18, 23]

"
Create Employee class (id,name,department) create Department class(departId,depart
name) create Hashmap and put diff employee id as key and employee obj as value and
sort by departId

Search an element in rotated and sorted array.

.What is a prime number and can you tell me the program to write it?

diamond problem in java

how u write code for rest api to get student by id

Sum of elements in Array with Java 8 ?

Query to write the all the employees who have age above 30 ?

Query for unique name of employee ?

Query for 1st 10 records from the table ?

Query for top 10 records sort by ascending order age above 30 ?

" class A {

public void m1(){

System.out.println(""A - m1"");

public abstract void m2();

class B extends A{

public void m1() {

System.out.println(""B - m1"");
}

public void m2(){

System.out.println(""B - m2"");

class Test {

public static void main(String[] args){

A a = new B();

a.m1();

a.m2();

}"

" class A {

private int i = 1;

class B extends A {

public void show(){

System.out.println(i);

public static void main(String args){

new B().show();

}"

" class A {

public void m1() {

System.out.println(""A - m1"");

class B extends A {

public void m1(){


System.out.println(""B - m1"");

class C extends A {

public void m1() {

System.out.println(""C - m1"");

}"

"class Test {

public static void main(String[] args){

A a = new C();

a.m1();

a = new A();

a.m1();

a = new B();

a.m1();

}"

there are 4 table...we write only one query for fetching all table data

" I want to display salary and below I that I want to display

all employees having that salary? which u will use?

ex. 50000

emp1

emp2

emp3

85000

emp9

emp10"
" I want to register user for vaccination according to their age

if age is higher then he should be registered first."

Reverse string with stringBuilder.

"public class Demo{

psvm(String[] args){

try{

Sop(""1"");

int i=10/0;

catch(NullPointerException e){

Sop(""2"");

try{

Sop(""3"");

int i=20/0;

catch(ArithematicException e){

Sop(""4"");

e.printStackTrace();

}"

"Largest palindrome substring

String=""babad""

Output-bab

Or

Output-aba"

"Diagonal matrix program

1000

0100
0010

0001

10001

01010

00100

01010

1 0 0 0 1"

"Statement

public class A{}

public class B{}

public abstract class C {}

public abstract class D

public interface E {}

public interface F {}

which is correct from follow options

1 A a = new C();

2 C a = new C();

3 class abstract C extends A , B

4 public class A implements B extends E , F

5 public abstract class C extends D implements E , F"

Create a sublist of employees whos name start with s and are from India

"class A{

Public string method() throws Exception {

}
Class B extends A{

Public string method() throws RuntimeException

}"

How can u write dynamically from 1 to 10 elements without using integrator or for loops
or any types of loops

If B class contain element of A class but A class can not contain element in B class write
query for that.

Fibonacci series program

Singleton program

Occurance of string

"1)Loop through 1 to 100

No divisible by 3 print 3

No divisible by 5 print 5

No divisible by 3 & 5 print got it

"

"2)

Print string without reverse method.

And store value in new string.

second max value from using single for loop only

"

Program on Overloading Overriding, Questions on cases as well as difference

"Array Program-

To find index of specific num from array

Ex- int a[]= {2,6,4,8,9,3}

Index of 4 is 2

"

Write a program to print 2nd max array number

write a program count the occurrence of words in string

class A{
void run(){walk();}

void walk(){}

class B extends A{

void run(){super.run()}

void walk(){super.walk()}

main{ A a = new B();

a.run();

what happend in this case

hashmapvalue.put("one",1);

hashmapvalue.put("two",2);

hashmapvalue.put("one",3);

try{

}catch(Exception e){

catch(NullpointerException ne){

in this senario finally block will execute or not

try{

}catch(Exception e){

system.exit1;

}finally{

12)Write program to reverse a string without using reverse function.

13)Write a program to print duplicate characters from string.


3) Write a program to swap two numbers without using third number.

4) Write a program to remove duplicates from arraylist.

5) Write a program to reverse string without using reverse function .

6. output

Class Organization{

Organization(int a)

SOP(“Organization”);

Static

SOP("Static”);

SOP(“instance”);

Public void test(){

SOP(“Parent”);

Class Employee extends Organization{

Employee(){

SOP(“Employee”);

Public void test(){

SOP(“Child”);
}

7. Output

try {

String s= null;

int l = s.length();

System.out.println("1");

}catch(NullPointerException ex) {

System.out.println("2");

throw ex;

}catch(Exception e) {

System.out.println("3");

}finally {

System.out.println("4");

4.even number program by using lambda expression

5.even number program by using arraylist

6.user class arraylist sort operation by using parameter name

{1,2,3,4,5} ==which collection will you use to get in reverse order. (don’t use sort
operation)

Two functional interfaces are their A and B. If B extends A will it work?

Suppose u have class Address with properties like street name, city name and another
class Employee with two properties name and reference variable of Address class. Now
make Employee class immutable but u cannot change anything in address class. How will
u achieve that? (ans create a clone and return clone)

List of employee object (3 columns =id name age).In Employee class I am setting 1000
employees in a list. Find which age how many times repeated. Store in map(key will be
the age and value count (is how many times the age will be repeated)

4) program on counting notes from the given inputs(notes like


2000,500,200,100,50,5,1)

5) program on finding two array are equal or not?

Given an array A of positive integers. Your task is to find the leaders in the array. An
element of an array is leader if it is greater than or equal to all the elements to its right
side. The rightmost element is always a leader. {16, 17, 4, 3, 5, 2}

2)How do you check if a string contains only digits?


12345678

53464esdg

for(){

for(){

for(){

How to break outer two loops?

11.how to convert list containing integer elements to long data type

Q. ask the logic of palindrom? what will you do when string is 3gb size what will you
use?

Q. ask the programe for fibbonacci series useing recusrion?

Program to merge to array and sort them

4)write a program to count the string which comes most

Q. give one list of string and ask program to find the string with maximum length?

Wap to print the numbers repeating in a integer array

9.Factorial Program(Dynamic input)

2.Palindrome

3.Anagram

wap to print charaters and its count in str…

) string s1=new string("xyz")

String s2=new string("ABC")

String S1="xyz"

S=s1+s2

S. O. P. (S)

4) in open space there are 10 dogs and in that 4 dogs are different types(labradog,
German Shepherd, dabarman) one by one going inside the middle and bark so tell me
the logic for that

5) let's suppose I have 2 threads T1, T2 both threads are calling one object O so what
you can do in this what logic you will apply so that single thread is calling to that object

Given any number, find the next possible greater number just by rearranging the digits

eg:
123 --> 132

1239641 ---> 1241369

Coding question:2

00111

11111

11111

00111

00001

Using the list or aaraylist sorting data into ascending order

Using the list or aaraylist sorting data into descending order

Sort data by using employee name

6) write a program of printing duplicate word occurance from string

7) write a program for reverse string using recursion

8) sort hashmap by using value

Write a program for duplicate numbers in an array.

try { }

catch (NPE | Arth E){ }

String name[]=”hello world”

Output= “world hello”

//Write a program to print the frequency of characters in a word

//For Eg: apple

//a=1,p=2,l=1, e=1

Reverse String

1.fabilocci series

2.prime number

3.find midle element of linkedlist


4.code of immutable class

5.Code Of singleton

6.sample code for rest api

1. What is Synchronization?

class A{

public void synchronised m1()

public void synchronised m2()

public static void main(String[] args){

A o1=new A();

a o2=new A();

thread t1 = new thread(runnable(o1.m1))

thread t2 = new thread(runnable(o2.m1))

Which tread will execute first?

3. What is locking of thread?

5.public Static void m1{

int[] a ={1,5,25,10,0,15,4,7}

int k=15;

Write a code to find out the pair of numbers whose sum is 15.

6. WAP to print list (string) in descending order

write a program to get repeated character and their count

write program to get char from string which occur max times.

9) write a program to find a duplicates value and also display the related key elements

4. WAP to find first duplicate character in a string except blank spece (without using any
inbuilt)

5. WAP to find str1 is substring of str2 (check it's occurrence) without using any inbuilt
method

2. WAP for occurance of character "Better Butter"

3. WAP to sort ages from array for adults and seniors using java 8 features

1) write program to find largest and second largest number in array.

14.program for duplicate character in string

15.program for below condition

1
22

333

4444

1. Program of swapping number using third variable and without third variable

2. Find second highest number in array

Logic for making calculator app

wap to get the character in string and their count in ascending

18.WAP encapsulated class with getter ahe setter on notepad

19. WAP to find minimum and maximum no. In array

4. Star pattern code

5.program on array findout closest number as given target number.

5. Program to print duplicate words

1.program for string s="swiss" print that character which is not repeated in string

8. Write a program to print fibonacci series by using recursion

Compare Version Number

Compare two version numbers version1 and version2.

• If version1 > version2 return 1,

• If version1 < version2 return -1,

• otherwise return 0.

You may assume that the version strings are non-empty and contain only digits and the .
character.

The . character does not represent a decimal point and is used to separate number
sequences.

WAP to get list of employee object from a given list who has salary above

25000 using stream api.

Use comparable and comparator to sort employee objects based on name and id.

Tell me logic to sort array of integer 54321

Write a program for greatest common factor

List<Integer> list = new ArrayList<>();

list.add(1);

list.add(2);
List list2 = list;

list2.add("Three");

list2.add(4.0);

System.out.println(list2);

for (Object num : list) {

System.out.println(num);

for (Integer num : list) {

System.out.println(num);

Output=?

9. code to print in the below format

**

**

**

Program to read the words from .txt file and calculate the frequency of word

WAP for count word occurrence using collection

5.program on sorting the arraylist

7 multithreding concept and create 10 thread program

9) write a program for synchronization.

You might also like