Coding Output and Program Question
Coding Output and Program Question
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=""babad""
Output-bab
Or
Output-aba
String=""abba"";
Output-bb
1000
0100
0010
0001
10001
01010
00100
01010
10001
"
"string objects means pool and heap concepts, how much objects will be created from
"
"Statement
public interface E {}
public interface F {}
1 A a = new C();
2 C a = new C();
"
"class A{
Public string method() throws Exception {
Class B extends A{
"
How can u write dynamically from 1 to 10 elements without using integrator or for loops
or any types of loops
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
Factorial of a number
I have text file I want to know which word occurred multiple items?
Reverse string
Factorial of a number
Reverse string
"String s=""java"";
"
if (str1.equals(str)2))
if (str1 == str2)
"
"Class A
Void M1(object o)
Class B
Void M1(string s)
Class C
M1(null)
O/p=?
"
"Class A
Void M1(Integer i)
Class B
Void M1(string s)
Class C
M1(null)
O/p=?
"
"Q.
111111
111122
111333
114444
155555
666666
"
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.
Main()
"
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;
Return the sum of both the diagonals of any NxN matrix i.e. int[][].
"
"
"Write a method to return the square of a number without using
"
"Print numbers from 1 to 100 without using any loop or iterators or Stream.
"
"
"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
String str=” java is Object oriented programming language”; , Write code to remove
extra space
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
p.run()
which methods will get called from which class and sequence
"
write a program of array that if similar elements should be added and if all the element
are same then output shoud be 0.
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.
"
String s= ""meeting""
String s1=""meet""
"
String s= ""nikhil"";
String s1=""nitesh"";
"
How to find middle elements of array if you don't know array size
**
**
**
***
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
"
String s1=""java"";
"
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
string s1=""abc"";
"
"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
"
Sum : 6
"
"3] str=""vishal"";
str.concatenate(""kawthale"");
sysout(str)
"
Find second max value from array using single for loop
"
"
"
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?
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
"
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 fetch the person name whose age is greater than 50?
"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]"
"class A{
Sop(hello);
}}
Class B extends A{
Sop(hello);
}}
B b= new B();
B.add();"
"class A {
class B extends A{
A a1 = new B();
a1.read();
}"
thread.start();
What will be the behaviour when you compile & run above code snippet?"
"class A {
final int i;
A a1 = new A();
a1.read();
System.out.println(i);
What will be the behaviour when you compile & run ?"
etch the record from Report table and Ids are 23,25,29.( select * from report where id
in(23,25,29);
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.
List<Integer> sortedList =
list.stream().sorted().collect(Collectors.toList());
System.out.println(list);
System.out.println(sortedList);
o/p
"
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
.What is a prime number and can you tell me the program to write it?
Query to write the all the employees who have age above 30 ?
" class A {
System.out.println(""A - m1"");
class B extends A{
System.out.println(""B - m1"");
}
System.out.println(""B - m2"");
class Test {
A a = new B();
a.m1();
a.m2();
}"
" class A {
private int i = 1;
class B extends A {
System.out.println(i);
new B().show();
}"
" class A {
System.out.println(""A - m1"");
class B extends A {
class C extends A {
System.out.println(""C - m1"");
}"
"class Test {
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
ex. 50000
emp1
emp2
emp3
85000
emp9
emp10"
" I want to register user for vaccination according to their age
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=""babad""
Output-bab
Or
Output-aba"
1000
0100
0010
0001
10001
01010
00100
01010
1 0 0 0 1"
"Statement
public interface E {}
public interface F {}
1 A a = new C();
2 C a = new C();
Create a sublist of employees whos name start with s and are from India
"class A{
}
Class B extends A{
}"
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.
Singleton program
Occurance of string
No divisible by 3 print 3
No divisible by 5 print 5
"
"2)
"
"Array Program-
Index of 4 is 2
"
class A{
void run(){walk();}
void walk(){}
class B extends A{
void run(){super.run()}
void walk(){super.walk()}
a.run();
hashmapvalue.put("one",1);
hashmapvalue.put("two",2);
hashmapvalue.put("one",3);
try{
}catch(Exception e){
catch(NullpointerException ne){
try{
}catch(Exception e){
system.exit1;
}finally{
6. output
Class Organization{
Organization(int a)
SOP(“Organization”);
Static
SOP("Static”);
SOP(“instance”);
SOP(“Parent”);
Employee(){
SOP(“Employee”);
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");
{1,2,3,4,5} ==which collection will you use to get in reverse order. (don’t use sort
operation)
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)
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}
53464esdg
for(){
for(){
for(){
Q. ask the logic of palindrom? what will you do when string is 3gb size what will you
use?
Q. give one list of string and ask program to find the string with maximum length?
2.Palindrome
3.Anagram
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
Coding question:2
00111
11111
11111
00111
00001
try { }
//a=1,p=2,l=1, e=1
Reverse String
1.fabilocci series
2.prime number
5.Code Of singleton
1. What is Synchronization?
class A{
A o1=new A();
a o2=new A();
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.
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
3. WAP to sort ages from array for adults and seniors using java 8 features
1
22
333
4444
1. Program of swapping number using third variable and without third variable
1.program for string s="swiss" print that character which is not repeated in string
• 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
Use comparable and comparator to sort employee objects based on name and id.
list.add(1);
list.add(2);
List list2 = list;
list2.add("Three");
list2.add(4.0);
System.out.println(list2);
System.out.println(num);
System.out.println(num);
Output=?
**
**
**
Program to read the words from .txt file and calculate the frequency of word