0% found this document useful (0 votes)
21 views5 pages

Java Questions

About Java

Uploaded by

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

Java Questions

About Java

Uploaded by

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

1.

Create a java application where we have to print hello world statement on the
console.
2. Create a java application where we have a local variable inside the main method
and print that variable by using print statement.
3. Create a java application where we have a global static variable print its
variable under main method.
4. Create a java application where we have one class it contains global non static
variable print this variable under main method.
5. Create a java application where we have one class it contains non static
variable int with value then print this value under main method.
6. Create a java application where we have one class it contains static variable
double the value then print this value under main method.
7. Create a java application where we have one class it contains two local
variables then perform addition, subtraction and multiplication and print the
result.
8. Create a java application where we have one class it contains non static
methods display() having no parameter, which is going to return nothing then print
any message when we invoke this method under main method.
9. Create a java application where we have one class it contains one non static
method like display having parameter as String and print that String value under
the method and this method goings to return nothing then invoke this under main
method.
10. Create a java application where we have one class it contains static method m1
having parameters int then print the value of parameter ,which is going to returns
nothing invoke this method under main method
11. Create a java application where we have one class it contains non-static method
m1 having parameter float , which is going to return nothing , static method m2
having parameter String , which is going to return nothing then invoke these 2
methods under main methods
12. Create a java application where we have one class it contains staticmethod m1
having parameter long , which is going to returns boolean values then invoke this
method under main method .
13. Create a java application where we have one class it contains non-static method
m1 having parameter character , which is going to returnsdouble value , non-static
method m2 having parameter int , which isgoing to return string value then invoke
these 2 methods under main method .
14. Create a java application where we have one class it contains one instance
variable and one static variable and non static method like m1, and static method
m2, which has no parameter and returns nothing print those global variables under
each method invoke m1 and m2 method under main method.
15. Create a java application where we have one class it contains one String type
of instance variable without initialisation and one static method m1 having String
as parameter and returns nothing initialize the global variable inside the m1
method and invoke m1 method and instance variable under main method.
16. Create a java application where we have one class it contains non static method
m1 having parameter float which is going to returns nothing then invoke this method
under main method by proving dynamic inputs.
17. Create a java application where we have one class it contains a non static
method m1 having parameter float and returns nothing. A static method m2 having
parameters integer returns nothing and A non static method m3 having parameter
Boolean returns nothing. Then invoke all these methods under main by providing
dynamic inputs
18. Create a java application where we have one class it contains one instance
variable String type and one static varibale float type and one local variable with
dynamic inputs print its 3 variables under main method.
19. Create a java application where we have one class it contains one non static
method m1 having a parameter int and it is going to return an int value and then
invoke this method under main method by providing dynamic inputs.
20. Create a java application where we have one class it contains methods like
static m1 having parameter boolean which is going to return a boolean value non
static method m2 having parameter char which is going to return char value static
method m3 having parameter double which is going to return a double value non
static method m4 having parameter long which is going to return long value static
method m5 having parameters float which is going to return float value non static
method m6 having parameter string which is going to return string then invoke all
these methods under main method by providing dynamic inputs.
21. Create a java application where we have one class it contains one non-static
method like m1 having a parameter integer and is going to return nothing, the
nonstatic method m2 has a parameter string and it is going to return nothing,
nonstatic method m3 has a parameter float and it returns nothing, nonstatic method
m4 having parameter boolean and it is going to return nothing, nonstatic method m5
having parameter double and it returns nothing. then invoke m1 method under m2, m2
method under m3, m3 under m4, m4 under m5 and m5 under main method by providing
dynamic input
22. Create a java application where we have one class it contains one non-static
method m1 having the parameter String and is going to return an integer value, and
a static method m2 having the parameter Boolean and it is going to return a float
value, a non-static method m3 having parameter character and it is going to return
a double value, then invoke all these methods under the main by providing dynamic
inputs for both parameters and return types.
23. create a java application where we have one class where we have methods like
non-static method m1 having parameter string and it is going to return an integer
value, static method m2 having parameter boolean and it's going to return an
integer value. then invoke m1 method under m2, m2 has to return the integer value
with addition of m1 return value, then invoke m2 under main by taking dynamic
inputs
24. Create a java application where we have one class it contains static method m1
having parameter like long , boolean , float and returns short value , static
method m2 having parameters like int , String , byte , and returns char value then
invoke m1 under m2, m2 under main by providing dynamic inputs .
25. Create a java application where we have one class it contains 2 instance
variable string , double and two static variables int , float and we have method
like display print global variables under this method Invoke this method under main
with 3 deffent objects.
26. create a java application where we have one class, it contains methods like add
having two parameters as integers, it is going returns the value as the addition of
two formal parameters, method sub having two parameters as integers and it is going
to return the value as subtraction of two parameters, method multi which doesn't
have any parameters and it has to return the value as multiplication of both ‘add’
and ‘sub’ method results. then invoke multi under the main method by providing
input values dynamically
27. Create a java application where we have one class, it contains methods like m
having parameter String it is going to return boolean value, method n having
parameter boolean and it is going to return double value,then invoke m under n
method and n method under main method by providing dynamic inputs
28. Create a java application where we have one class it contains methods like M1
having a parameter string and it is going to return a Boolean value, method M2 has
a parameter float and it is going to return nothing then invoke method M1 under M2
and then M2 under the main method by providing dynamic inputs
29. Create a java application where we have one class it contains methods like M1
which does not have any parameter and returns nothing, method M2 which does not
have any parameter and returns nothing then invoke M1 under M2 and then M2 under
the main method, both M1 and M2 methods have to print any user-friendly message on
the console
30. Create a java application where we have one class it contains methods like M1
does not have any parameter and it has to return a float value, method M2 which
does not have any parameter and returns a Boolean value then invoke method M1 under
M2 and then invoke method M2 under the main method by providing dynamic inputs
31. Create a java application where we have one class it contains two non-static
methods having parameter and return type then invoke this methods under main method
without storing the object.
32. Create a java application where we have one class it contains non-static method
m1 having no parameter , returns nothing ,static- method m2 having no parameter
returns nothing, non-static method m3 having parameter float, return nothing,
static method m4 having parameter boolean returns nothing , non-static method m5
having no parameter returns String static method m6 having no parameter return long
value non-static method m7 having parameter double returns short value static
method m8 having parameter int , returns charcter value then invoke m1 under m2 ,
m2 under m3, m3 under m4, m4 under m5, m5 under m6 , m6 under m7, m7 under m8, m8
under Main by providing dynamic inputs
33. create a java application where we have one class, it contains nonstatic method
m2 having parameter string and it is going to return a boolean value, static method
m3 having parameter integer and it is going to return char value then invoke m2
under m3 and then m3 under the main method by providing dynamic inputs without
using the import keyword.
34. Create a Java Application where we have one class it contains one static method
m1 having no parameters and returns a Class variable, nonstatic method m2 having a
parameter boolean and returns nothing, then invoke both methods under the main by
providing dynamic inputs and without creating an object or without using object
reference directly.
35. Create a java application where we have one class it contains two instance
variables and two instance methods having paramter and return type and static
methods having parameter and return type then invoke non static methods under
static method each and print instance variables under both static methods and
invoke static methods under main method by providing dynamic inputs (note : only by
using obj reference).
36. Create a java application where we have one class it contains default
contructor which prints a user freindly msg when we invoke it.
37. Create a java application where we have one employee they have to display the
details empId, name, salary, disignation and mobile number by using the
parameterized constructor, then invoke the constructor under main by providing
dynamic inputs.
38. Create a Java Application where we have one static variable integer, two non-
static variables Boolean and double, one non static method with parameter char and
returns long value, a default constructor and a parameterized constructor. then
invoke all the properties under main by providing dynamic inputs.
39. create a java appliaction where we have one class it contains 3 instance
variables without intialization,then initialize those variables while creating
objectby providing dynamic inputs
40. Create a java application where we need to create any two constructors and then
invoke any one constructor under main method from there it has to invoke the
remaining constructor.
41. Create a java application where we need to create one object parameterized
constructor it has to display a userfriendly message on the console when we invoke
this constructor in the main method.
42. Create a java application where we need to create 3 constructors invoke all the
constructors in a single line.
43. create a java application where we have one class it contains 2 instance
variables without intialization then intialize those varaibles while creating obj
and display them under an object parameterized constructor here i should get both
default values and user given values of the global variables.
44. create a Java application where we need to satisfy this keyword at a variable
level.
45. create a java application where we have one class it contains three methods m1
has a parameter integer and it is going to returns a String value, method m2 having
parameter float and it is going to return boolean value and method m3 having
parameter string and it is going to return double value then invoke m3 under main
method, m2 under m3 and m1 under m2 by using this keyword with dynamic inputs.
46. Create a java application where we have one class it contains constructors like
a single parameter as Integer, default, double parameter as String and boolean, and
Tripple parameter like double long and character. then invoke a single parameter
under default, default under double parameter, and double under Tripple and Tripple
under main by using this keyword with dynamic inputs.
47. Create a java application where we have one class it contains three instance
variables without values and it contains static methods like m1,m2,m3 having no
parameters and with return type and it contains one thriple parameterized
constructor having m1, m2, m3 methods return value as parameter, and initialise
global variables by using thriple parameterized constructor.
48. Create a java application where we have one class, it contains a non static
variable and static method m1 having parameter ad return type and a non static
method m2 having parameter and return type then inherit this class into another
class which contains one non static variable and non static method, then invoke all
this under main method of derived class.
49. Create a java application where we have class bank it contains an instance
variable balance with static input and 2 non static methods like withdraw and
deposit take repsective parameter and return types to do the operations and non
static method balance enquiry which displays the current balance then inhert this
class into class user where we have non static method like banking from here invoke
respective method of bank class based on user input after completion one
transcation ask user if he wants to do one more transaction or to exit and based on
user input do the operations by providing dynamic inputs.
50. Create a Java app where we have one class it contains one DC then inherit this
class into the DC of another class then inherit this class into the PC of another
class and then this class into the PC of another class and then inherit this class
into the DC of another class. then if we invoke the bottommost derived class
constructor under the main method from there it has to invoke intermediate base
class constructors by using the super keyword and then from there it has to invoke
top most base class constructor by using a super keyword by giving dynamic inputs.
51. Create a java applicationn where we have to satisfy super at all levels
53. create a java application where we have one class like Gmail which contains 2
private fields like email and password, provide values for these properties using
constructor injection
and create an object like user1 under a seperate class like User. after creating an
account for that user now try to login by taking seperate variables under main
method. if these variable
values match with private fields of Gmail class print login successfull else print
login failed.

54. Create a java application where we have class Insta it contains 3 private
fields like U_N , P_S and Ph_no then provide getter and setter methods for these
variables.we have a seperate class User it contains a method like register here ask
user to enter credentials
like U_N , P_S and ph_no and set this values by using constructor injection and
another method like login in this method ask user to enter credentials like U_N and
P_S then compare these values with existing details in Insta if both matches then
print "LogIn Success"
if both dosen't match then ask user for ph_no and if dosent matches with existing
Ph_no print user not found and ask user to enter valid Ph_no,if it matches then
send an otp for user by using a
method like otpGenerator and display it in a method like display and ask user to
enter otp if it matches with otp sent by insta then display U_N and P_S to the
user and redirect him to login or
else print invalidOtp.if any one of the credential mis-matches then ask user
weather to update it or not if yes then update them by asking new values after
verifying Ph_no and then redirect them to login after updating the fields.
55. Create a java application where we have two abstract classes it contains one
abstract method each then inherit one abstract class into another abstract class
and then inherite abstract class into concret class and provide functionality for
abstract method and invoke those method by using dynamic inputs.
56. Create a java application where we have one abstract class it contain one
parameterized constracter and two abstract methods having return type and
parameters & we have two interfaces contains one undefined each then provide
functionality for all the abstract methods in a concret class at a time and invoke
all properties by providing dynamic inputs.

You might also like