ASSIGNMENT Questions Course
ASSIGNMENT Questions Course
1(Theory):
------------
The meaning of Java platform-independent is that the Java compiled code(byte code) can run on
all operating systems.
JAVA Open source software is software with source code that anyone can inspect, modify, and
enhance.
"Source code" is the part of software that most computer users don't ever see; it's the code
computer programmers can manipulate to change how a piece of software—a "program" or
"application"—works. Programmers who have access to a computer program's source code can
improve that program by adding features to it or fixing parts that don't always work correctly.
JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn't
physically exist. It is a specification that provides a runtime environment in which Java bytecode can
be executed. It can also run those programs which are written in other languages and compiled to
Java bytecode.
JVMs are available for many hardware and software platforms. JVM, JRE, and JDK are platform
dependent because the configuration of each OS is different from each other. However, Java is
platform independent. There are three notions of the JVM: specification, implementation,
and instance.
JRE is an acronym for Java Runtime Environment. It is also written as Java RTE. The Java Runtime
Environment is a set of software tools which are used for developing Java applications. It is used to
provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a
set of libraries + other files that JVM uses at runtime.
The implementation of JVM is also actively released by other companies besides Sun Micro Systems.
JDK
JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a software
development environment which is used to develop Java applications and applets. It physically
exists. It contains JRE + development tools.
JDK is an implementation of any one of the below given Java Platforms released by Oracle
Corporation:
Standard Edition Java Platform
Enterprise Edition Java Platform
Micro Edition Java Platform
The JDK contains a private Java Virtual Machine (JVM) and a few other resources such as an
interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc),
etc. to complete the development of a Java Application.
Java is object-oriented. This allows you to create modular programs and reusable code. Java is
platform-independent. One of the most significant advantages of Java is its ability to move easily
from one computer system to another.
5.What is the latest version of JDK and which version you are using in your project?
JDK 21 is the latest long-term support release of Java SE Platform and I use JDK 1.8 in most of my
projects.
6.What is the latest version of eclispe and which version you are using in your project?
4.30.0 is the latest version of eclipse and we are using oxygen eclipse 3a
C++ Java
C++ is designed to work with compiler only Java can support both compiler and interpreter
C++ uses “cin” and “cout” Complex in/out methods (System.in and System.out)
C++ can provide multiple inheritances Java cannot support multiple inheritances
C++ supports structures (custom data type) Java does not provide structures
C++ needs manual class and object management using Java is completely automatic regarding class and object
new and delete keywords management
C++ needs manual garbage memory clearance Java has an automatic garbage collector
8.Features of java?
1) Simple. Java is easy to learn and its syntax is quite simple, clean and easy to understand.
2) Object Oriented. In java, everything is an object which has some data and behaviour.
3) Robust.
4) Platform Independent.
5) Secure.
6) Multi Threading.
7) Architectural Neutral.
8) Portable.
9)High performance
10)Distributed
9.What type of tool you are using in your project to execute java?
class:
a class describes the contents of the objects that belong to it: it describes an aggregate of
data fields (called instance variables), and defines the operations (called methods).
object:
an object is an element (or instance) of a class; objects have the behaviors of their class. The
object is the actual component of programs, while the class specifies how instances are
created and how they behave.
method:
a method is an action which an object is able to perform.
In such case, import the class having the method in the invoking class of a different package. If the
method is static, access the method using ClassName,methodName. If the method is an instance
method, then access the method by creating an object of the class in which the method resides.
13.What is encapsulation?
Encapsulation in Java refers to integrating data (variables) and code (methods) into a single unit. In
encapsulation, a class's variables are hidden from other classes and can only be accessed by the
methods of the class in which they are found.
1. Use descriptive and appropriate names for all identifiers (variables, method names, class
names, constants, etc.).
2. Comment every 3-7 lines of code.
3. Be neat.
4. Use descriptive names for all variables, function names, constants, and other identifiers.
5. Use single letter identifiers only for the counter in loops.
6. Class names start with an upper case letter.
7. Variable names start with a lower case letter. (Variables include parameters, local variables,
and data fields. Exception: use UPPER_CASE for constants - final variables.)
8. Method names start with a lower case letter.
9. Multi-word identifiers are internally capitalized.
10. Do not use hyphens or underscores to separate multi-word identifiers (except for constants,
which have all upper case letters).
11. Every class should be preceded with a descriptive comment using the "JavaDoc" notational
convention.
12. The comment should describe its purpose of the class.
13. Class names start with an upper case letter.
14. Every method definition should be preceded with a descriptive comment using the
"Javadoc" notational convention.
15. The comment should include a description of the method, the name and description of each
parameter, a description of the return value, and the name and description of any
exceptions thrown within the method using Javadoc keywords and formatting.
16. Detailed description line by line:
17. Begins with a slash, followed by two asterisks (/**)
18. One asterisk (*)
19. One asterisk (*), followed by @param, followed by the name of the parameter, followed by
a description of the parameter (Omit if there are no parameters. Use one line for each
parameter, so two parameters will have two lines. 3 parameters will have 3 lines. Etc.)
20. One asterisk (*), followed by return, followed by a description of the return variable (Omit if
the return value is void.)
21. One asterisk (*), followed by @exception, followed by the class of the exception, followed
by a description of when the exception is thrown. Only checked exceptions are required to
be listed. Unchecked exceptions are not required to be listed. Omit exceptions if there are
no exceptions that are thrown. (In other words, if you catch the exception within the
method, you do not need to list the exception.) Use one line for each exception, so two
exceptions will have two lines. 3 exceptions will have 3 lines. Etc.
22. Ends with one asterisk, followed by one slash (*/)
23. Every public variable should be preceded with a descriptive comment using the "JavaDoc"
notational convention. The comment should describe the purpose for the public variable.
24. In-line comments should be used to explain complicated sections of code, such as loops. Use
the // comment delimiter for in-line comments. Do not comment generally known features
of the java language.
25. Use two blank lines to separate each method within a class definition. Use one blank line to
separate logical sections of code within a method.
26. Put a single space before every "{".
27. Separate all binary operators, such as "+", "-", "*", "/", "%", etc., with a single space. The
exception is unary operators, such as "++", "--", unary minus "-", etc, which do not need to
be separated with a single space.
28. Indent two spaces when beginning a new block.
29. Open braces (i.e. "{") do not start a new line.
30. Close braces (i.e. "}") do start a new line, and are indented with the code they close.
31. Comments line up with the block they comment.
32. Classes begin with a capital letter.
33. Packages are all lower case.
34. Methods begin with a lower case letter.
35. Multi-word identifiers are internally capitalized in methods (CamelCase).
36. Lines of code should be kept short, generally less than 80 or 100 characters wide.
37. Each public class is contained in a separate file.
38. Each file has the name of the public class contained within it.
39. Avoid the use of the default package.
15.What gives Java it's "write once and run anywhere" nature?
What gives Java its 'write once and run anywhere' nature? The Bytecode. Java compiler converts the
Java programs into the class file (Byte Code) which is the intermediate language between source
code and machine code. This bytecode is not platform-specific and can be executed on any
computer.
Description:
Create an object for employee class and call above methods also follow the all coding standards.
Solution:
package org.employee;
//class name
public class Employee {
}
private void employeename() {
// TODO Auto-generated method stub
System.out.println("Employee name is svasanth");
}
private void employeedob() {
// TODO Auto-generated method stub
System.out.println("Employee dob is 19-06-2000");
}
private void employeeemail() {
// TODO Auto-generated method stub
System.out.println("Employee Email is [email protected]");
}
private void employeeaddress() {
// TODO Auto-generated method stub
System.out.println("Employee address is no.6/13,Muthappa Mudali
street, cross, sanrorkuppam, ambur-635814");
//method calling
//object name.methodname
e.employeeid();
e.employeename();
e.employeedob();
e.employeephone();
e.employeeemail();
e.employeeaddress();
//empId(),empName(),empDob(),empPhone(),empEmail(),empAddress()
}
}
Result:
Employee id is 1
Employee name is Vasanth
Employee Date of Birth is 19-06-2000
Employee phone number is 6369793294
Employee Email is [email protected]
Employee address is no.6/13,Muthappa Mudali street, cross, sanrorkuppam,
ambur-635814
QUESTION 2:
-------------
Project :GreensAddress
Package :org.add
Class :GreensTech
Methods :greensOmr(),greensAdayar(),greensTambaram(),greensVelacherry(),greensAnnaNagar()
Description:
Create an object for GreensTech class and call above methods also follow the all coding standards.
Solution:
package org.add;
//class name
}
public void greensadayar() {
// TODO Auto-generated method stub
System.out.println("\r\n" +
"Adyar,\r\n" +
"11 First Street Padmanabha Nagar,\r\n" +
"Chennai\r\n" +
"Tel: +91- 72005 52296");
}
public void greenstambaram() {
// TODO Auto-generated method stub
System.out.println("\r\n" +
"Tambaram,\r\n" +
"11 First Street Padmanabha Nagar,\r\n" +
"Chennai\r\n" +
"Tel: +91- 72005 52296");
}
public void greensannanagar() {
// TODO Auto-generated method stub
System.out.println("\r\n" +
"Annanagar,\r\n" +
"11 First Street Padmanabha Nagar,\r\n" +
"Chennai\r\n" +
"Tel: +91- 72005 52296");
}
public void greensvelachery() {
// TODO Auto-generated method stub
System.out.println("\r\n" +
"Velachery,\r\n" +
"11 First Street Padmanabha Nagar,\r\n" +
"Chennai\r\n" +
"Tel: +91- 72005 52296");
}
//main -------- control + space
public static void main(String[] args) {
//object creation
//classname objectname=new classname
GreensTech_1 g=new GreensTech_1();
//method calling
//object name.methodname
g.greensomr();
g.greensadayar();
g.greensannanagar();
g.greenstambaram();
g.greensvelachery();
//greensOmr(),greensAdayar(),greensTambaram(),greensVelacherry(),greensAnna
Nagar()
}
}
Result:
OMR,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Adyar,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Annanagar,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Tambaram,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Velachery,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
ADDITIONAL PROGRAM:
Solution:
package org.add;
}
}
Result:
9784562234
9784562234
9784562234
QUESTION 3:
------------
Project :CompanyDetails
Package :org.company
Class :CompanyInfo
Methods :companyName(),companyId(),companyAddress()
Description:
Create an object for CompanyDetails class and call above methods also follow the all coding
standards.
Example for how to import all classes of one package at a time to another package using (*).
Solution:
package org.company;
import org.add.*;
//class name
public class CompanyInfo {
//method name = control + space
private void companyid() {
// TODO Auto-generated method stub
System.out.println("Company id is 1");
}
private void companyname() {
// TODO Auto-generated method stub
System.out.println("Company name is GT");
}
public static void main(String[] args) {
//object creation
//classname objectname=new classname
CompanyInfo c=new CompanyInfo();
//method calling
//object name.methodname
c.companyid();
c.companyname();
c.companyaddress();
//companyName(),companyId(),companyAddress()
//method calling
//object name.methodname
g.greensomr();
g.greensadayar();
g.greensannanagar();
g.greenstambaram();
g.greensvelachery();
Result:
Company id is 1
Company name is GT
Company address is no.2,3RD STREET,Tambaram
OMR,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Adyar,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Annanagar,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Tambaram,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
Velachery,
11 First Street Padmanabha Nagar,
Chennai
Tel: +91- 72005 52296
9784562234
9784562234
9784562234
QUESTION 4:
-----------
Project :MyPhone
Package :org.phone
Class :PhoneInfo
Methods :phoneName(),phoneMieiNum(),Camera(),storage(),osName()
Description:
Create an object for PhoneInfo class and call above methods also follow the all coding standards.
Solution:
package org.phone;
//classname
}
private void phonename() {
// TODO Auto-generated method stub
System.out.println("Employee name is Poco x5 pro");
}
private void camera() {
// TODO Auto-generated method stub
System.out.println("Front camera 16pixel" + "back camera
120 mega pixel");
}
private void storage() {
// TODO Auto-generated method stub
System.out.println("Internal 120gb expandable upto
256gb");
}
private void osname() {
// TODO Auto-generated method stub
System.out.println("Android");
//method calling
//object name.methodname
pi.camera();
pi.osname();
pi.phoneid();
pi.phonename();
pi.storage();
//phoneName(),phoneMieiNum(),Camera(),storage(),osName()
}
}
Result:
QUESTION 5:
------------
Project :LanguageDetails
Package :org.lang
Class :LanguageInfo
Methods :tamilLanguage(),englishLanguage(),hindiLanguage()
Class :StateDetails
Methods :southIndia(),northIndia()
Description:
Create an object for LanguageInfo and StateDetails inside the StateDetails class and call both classes
methods also follow the all coding standards.
Solution 1:
package org.lang;
LA.englishlanguage();
LA.tamillanguage();
LA.hindilanguage();
SD.southIndia();
SD.northIndia();
}
}
Result 1:
Hello
Vanakkam
Namasthe
Solution 2:
package org.lang;
public class StateDetails {
SD.southIndia();
SD.northIndia();
LA.englishlanguage();
LA.tamillanguage();
LA.hindilanguage();
}
Result 2:
Tamil Nadu
Delhi
Hello
Vanakkam
Namasthe
QUESTION 6:
-----------
Project :EmployeeInformation
Package :org.emp
Class :Employee
Methods :empName()
Package :org.company
Class :Company
Methods :companyName()
Package :org.client
Class :Client
Methods :clientName()
Package :org.project
Class :Project
Methods :projectName()
Description:
Create an object for all 4 classes inside the Employee class and call all classes methods also follow
the all coding standards.
Solution 1:
package org.client;
CLN.clientname();
}
}
Result 1:
Solution 2:
package org.company;
import org.client.Client;
import org.emp2.Employee;
import org.project.Project;
}
}
Result 2:
Company name is GT
Solution 3:
package org.project;
pn.projectname();
}
}
Result 3:
Solution 4:
package org.emp;
import org.client.Client;
import org.company.Company;
import org.project.Project;
E.employeename();
Result 4:
Class :InternalStorage
Methods :processorName(),ramSize()
Description:
Create an object for ExternalStorage and InternalStorage inside the InternalStorage class and call
both classes methods also follow the all coding standards.
Solution 1:
package org.phone;
es.size();
}
}
Result 1:
256gb
Solution 2:
package org.phone;
IS.internalstorage();
IS.processorname();
Result 2:
128gb
Snapdragon
256gb
QUESTION 8:
------------
Project :CollegeInformation
Package :org.college
Class :College
Methods :collegeName(),collegeCode(),collegeRank()
Class :Student
Methods :studentName(),studentDept(),studentId()
Class :Hostel
Methods :hostelName()
Class :Dept
Methods :deptName()
Description:
Create an object for all 4 classes inside the College class and call all classes methods also follow the
all coding standards.
Solution 1:
package org.college;
C1.college_code();
C1.college_name();
C1.college_rank();
D.dept_name();
H.hostel_name();
}
}
Result 1:
2124
SSIET
12
21
Vasanth
ECE
ECE
VIVEKANANDHA
Solution 2:
package org.college;
D.dept_name();
}
}
Result 2:
ECE
Solution 3:
package org.college;
Result 3:
VIVEKANANDHA
Solution 4:
package org.college;
S1.student_id();
S1.student_name();
S1.student_dep();
}
}
Result 4:
21
Vasanth
ECE
QUESTION 9:
------------
Project :VehicleInformation
Package :org.allvehicle
Class :Vehicle
Methods :VehicleNecessery()
Package :org.twowheeler
Class :TwoWheller
Methods :bike(),cycle()
Package :org.threewheeler
Class :ThreeWheeler
Methods :Auto()
Package :org.fourwheeler
Class :FourWheeler
Methods :car(),bus(),lorry()
Description:
Create an object for all 4 classes inside the Vehicle class and call all classes methods also follow the
all coding standards.
Solution 1:
package org.all.vehicle;
import org.fourwheeler.Fourwheeler;
import org.threewheeler.Threewheeler;
import org.twowheeler.Twowheeler;
V1.vehicle_necessary();
TW.bike();
TW.cycle();
THW.auto();
FW.car();
FW.bus();
FW.lorry();
}
}
Result 1:
Bike
honda
hero
pd
bmw
volvo
tata
Solution 2:
package org.fourwheeler;
FW.car();
FW.bus();
FW.lorry();
}
}
Result 2:
bmw
volvo
tata
Solution 3:
package org.threewheeler;
THW.auto();
}
}
Result 3:
Pd
Solution 4:
package org.twowheeler;
TW.bike();
TW.cycle();
}
}
Result 4:
honda
hero
QUESTION 10:
--------------
Project :TransportInformation
Package :org.transport
Class :Transport
Methods :TransportForm
Package :org.road
Class :Road
Methods :bike(),cycle(),bus(),car()
Package :org.air
Class :Air
Methods :aeroPlane(),heliCopter()
Package :org.water
Class :Water
Methods :boat(),ship()
Description:
Create an object for all 4 classes inside the Transport class and call all classes methods also follow
the all coding standards.
Solution 1:
package org.air;
ar.aeroplane();
ar.helicopter();
}
}
Result 1:
airlines
military
Solution 2:
package org.road;
rd.bike();
rd.bus();
rd.car();
rd.cycle();
}
}
Result 2:
yamaha-6 pulsar-4
BMW-1 AUDI-2
tata-3 hyundai-5
hero-3 bird-6
Solution 3:
package org.water;
Result 3:
titanic
cruise
Solution 4:
package org.transport;
import org.air.Air;
import org.road.Road;
import org.water.Water;
tt.transportform();
Road rd=new Road();
rd.bike();
rd.bus();
rd.car();
rd.cycle();
ar.aeroplane();
ar.helicopter();
}
}
Result:4
three
yamaha-6 pulsar-4
BMW-1 AUDI-2
tata-3 hyundai-5
hero-3 bird-6
airlines
military
titanic
cruise
QUESTION 11:
--------------
Project :NetworkInformation
Package :org.network
Class :Wifi
Methods :wifiName()
Class :MobileData
Methods :dataName()
Class :Lan
Methods :lanName()
Class :Wireless
Methods :modamName()
Description:
Create an object for all 4 classes inside the Wifi class and call all classes methods also follow the all
coding standards.
Solution 1:
package org.network;
lan.lanname();
}
}
Result 1:
Bsnl
Solution 2:
package org.network;
MD.dataname();
}
}
Result 2:
Jio
Solution 3:
package org.network;
wl.modemname();
}
}
Result 3:
airtel
Solution 4:
package org.network;
wf.wifiname();
MD.dataname();
lan.lanname();
Wireless wl=new Wireless();
wl.modemname();
}
}
Result 4:
ACE
jio
bsnl
airtel
Solution:
package org.student.details.scanner;
import java.util.Scanner;
sD = new Scanner(System.in);
sd1 = new Scanner(System.in);
Result:
Enter your id :
1
Your id is : 1
Enter your name :
Vasanth Sridhar
Your name is : Vasanth Sridhar
Enter your mark1 :
80
Your Mark1 is 80.0
Enter your mark2 :
56
Your Mark2 is 56.0
Enter your mark3 :
67
Your Mark3 is 67.0
Enter your mark4 :
78
Your Mark4 is 78.0
Enter your mark5 :
78
Your Mark5 is 78.0
Your total mark is : 359.0
Your average mark is : 71.8
QUESTION 3:
------------
package name: org.all
Project name: LanguageDetails
Class name : Languageclass
Methods : alllanguage
Description:
create above 4 packages and call all your class methods into the Languageclass using multilevel
inheritance.
Solution 1:
package org.english;
}
public static void main(String[] args) {
English EH=new English();
EH.englishlanguage();
}
}
Result 1:
Hello
Solution 2:
package org.telugu;
import org.english.English;
//CHILD CLASS //PARENT CLASS
public class Telugu extends English {
TG.telugulanguage();
TG.englishlanguage();
}
}
Result 2:
NAMASKARAM
Hello
Solution 3:
package org.tamil;
import org.telugu.Telugu;
//CHILD CLASS //PARENT CLASS
public class Tamil extends Telugu{
public void tamillanguage() {
// TODO Auto-generated method stub
System.out.println("VANAKKAM");
}
public static void main(String[] args) {
Tamil TL=new Tamil();
TL.tamillanguage();
TL.telugulanguage();
TL.englishlanguage();
}
}
Result 3:
VANAKKAM
NAMASKARAM
Hello
Solution 4:
package org.all.lang;
import org.tamil.Tamil;
//CHILDCLASS //PARENTCLASS
public class Languageclass extends Tamil {
LC.alllanguage();
LC.englishlanguage();
LC.telugulanguage();
LC.tamillanguage();
}
}
Result 4:
helloha
Hello
NAMASKARAM
VANAKKAM
QUESTION 4:
------------
package name: org.india
Project name: SouthIndia
Class name : India
Methods : india
package name: org.tamilnadu
Project name: SouthIndia
Class name : TamiladuN
Methods : tamillanguage
Description:
create above 4 packages and call all your class methods into the India using multilevel inheritance.
Solution 1:
package org.andhra;
AP.telugu();
}
Result 1:
Namaskaram
Solution 2:
package org.kerala;
import org.andhra.Andhra;
KL.malayalam();
KL.telugu();
}
}
Result 2:
swagatham
Namaskaram
Solution 3:
package org.tamilnadu;
import org.kerala.Kerala;
TN.tamillanguage();
TN.telugu();
TN.malayalam();
}
}
Result 3:
VANAKKAM
Namaskaram
Swagatham
Solution 4:
package org.s.india;
import org.tamilnadu.TamilNadu;
SI.southindia();
SI.malayalam();
SI.telugu();
SI.tamillanguage();
}
}
Result 4:
TAK
swagatham
Namaskaram
VANAKKAM
QUESTION 5:
-------------
Project :CollegeInformation
Package :org.college
Class :College
Methods :collegeName(),collegeCode(),collegeRank()
Class :Student
Methods :studentName(),studentDept(),studentId()
Class :Hostel
Methods :HostelName()
Class :dept
Methods :deptName()
Description:
create above 4 class and call all your class methods into the Student/College using multilevel
inheritance.
Solution 1:
package org.college;
HL.hostelname();
}
}
Result 1:
Vivekanandha
Solution 2:
package org.college;
Result 2:
ece
Vivekanandha
Solution 3:
package org.college;
SD.studentname();
SD.studentid();
SD.studentdept();
SD.hostelname();
SD.deptname();
}
}
Result 3:
Vasanth
1
ECE
Vivekanandha
ece
Solution 4:
package org.college;
CG.collegename();
CG.collegecode();
CG.collegerank();
CG.studentdept();
CG.studentid();
CG.studentname();
CG.deptname();
CG.hostelname();
}
}
Result 4:
SSIET
2124
21
ECE
1
Vasanth
ece
Vivekanandha
QUESTION 6:
-----------
Project :Computer
Class :Computer
Methods :computerModel()
Class :Desktop
Methods :desktopSize()
Description:
create above 2 class and call all your class methods into the Desktop using single inheritance.
Solution 1:
package org.computer.singleinheritance;
cm.computermodel();
}
}
Result 1:
Apple
Solution 2:
package org.computer.singleinheritance;
dt.desktopsize();
dt.computermodel();
}
}
Result 2:
500gb
Apple
QUESTION 7:
-----------
Project :LanguageDetails
Package :org.lang
Class :LanguageInfo
Methods :tamilLanguage(),englishLanguage(),hindiLanguage()
Class :StateDetails
Methods :southIndia(),northIndia()
Description:
create above 2 class and call all your class methods into the LanguageInfo using single inheritance.
Solution 1:
package org.lang2;
public class StateDetails {
public void southindia() {
// TODO Auto-generated method stub
System.out.println("TPKAK");
}
public void northindia() {
// TODO Auto-generated method stub
System.out.println("MMPDPH");
}
public static void main(String[] args) {
StateDetails STD=new StateDetails();
STD.northindia();
STD.southindia();
}
Result 1:
MMPDPH
TPKAK
Solution 2:
package org.lang2;
}
public static void main(String[] args) {
LanguageInfo_2 LF2=new LanguageInfo_2();
LF2.englishlanguage();
LF2.hindilanguage();
LF2.tamillanguage();
LF2.southindia();
LF2.northindia();
}
Result 2:
hello
Namaste
Vanakam
TPKAK
MMPDPH
QUESTION 8:
------------
Description: Using Scanner class get the below details
StudentId
StudentName
StudentEmail
StudentPhoneno
StudentDept
StudentGender
StudentCity
Refer to Example program in scanner class page no : it is same as this problem but here program is
executed for student instead of employee
QUESTION 9:
------------
Project :BankDetails
Package :org.bank
Class :BankInfo
Methods :saving(),fixed()
Class :AxisBank
Methods :deposit()
Description:
create above 2 class and call all your class methods into the BankInfo using single inheritance.
Solution 1:
package org.bank.si;
bi.saving();
bi.fixed();
}
}
Result 1:
Solution 2:
package org.bank.si;
ab.deposit();
ab.saving();
ab.fixed();
}
}
Result 2:
Deposit intrest is : 4%
saving account bal: 2000
fixed balence: 100000
QUESTION 10:
-------------
Project :CompanyDetails
Package :org.company
Class :Company
Methods :companyName()
Package :org.client
Class :Client
Methods :clientName()
Description:
create above 2 packages and call all your class methods into the Comapany using single inheritance.
Solution 1:
package org.company.si;
csi.companyname();
}
}
Result 1:
HCL
Solution 2:
package org.client.si;
import org.company.si.Companysi;
cli.clientname();
cli.companyname();
}
}
Result 2:
GT
HCL
QUESTION 11:
------------
Project :EducationInformation
Package :org.edu
Class :Education
Methods :ug(),pg()
Class :Arts
Methods :bsc(),bEd(),bA(),bBA()
Class :Engineering
Methods :bE(),bTech()
Class :Medicine
Methods :physiyo(),dental(),mbbs()
Description:
create above 4 class and call all your class methods into the Education using multilevel inheritance.
Solution 1:
package org.edu.mlih;
ar.bsc();
ar.b_ed();
ar.bba();
ar.ba();
}
}
Result 1:
Bachelor of science
Bachelor of education
Bachelor of Business Administration
Bachelor of Arts
Solution 2:
package org.edu.mlih;
eng.be();
eng.b_tech();
eng.bsc();
eng.ba();
eng.bba();
eng.b_ed();
}
Result 2:
Bachelor of Engineering
Bachelor of technology
Bachelor of science
Bachelor of Arts
Bachelor of Business Administration
Bachelor of education
Solution 3:
package org.edu.mlih;
med.physiyo();
med.dental();
med.mbbs();
med.be();
med.b_tech();
med.ba();
med.bsc();
med.b_ed();
med.bba();
}
}
Result 3:
Bachelor of physiyo
Bachelor of Dental Surgery
Bachelor of medicine and Bachelor of surgery
Bachelor of Engineering
Bachelor of technology
Bachelor of Arts
Bachelor of science
Bachelor of education
Bachelor of Business Administration
Solution 4:
package org.edu.mlih;
edu.ug();
edu.pg();
edu.dental();
edu.physiyo();
edu.mbbs();
edu.be();
edu.b_tech();
edu.bsc();
edu.bba();
edu.ba();
edu.b_ed();
}
}
Result 4:
Under Graduate
Post Graduate
Bachelor of Dental Surgery
Bachelor of physiyo
Bachelor of medicine and Bachelor of surgery
Bachelor of Engineering
Bachelor of technology
Bachelor of science
Bachelor of Business Administration
Bachelor of Arts
Bachelor of education
QUESTION 1:
------------
Find the answer for below questions and tell whether it is possible or not?
I implements I
I implements C
I implements A
I extends I
I extends C
I extends A
C implements I
C implements C
C implements A
C extends I
C extends C
C extends A
A implements I
A implements C
A implements A
A extends I
A extends C
A extends A
A-abstract class
C-class
I- interface
QUESTION 2:
------------
Project :EmployeeDetails
Package :org.emp
Class :Employee
Methods :empId()
Description
You have to overload the method empId() based on different datatype in arguments.
QUESTION 3:
------------
Project :CompanyDetails
Package :org.company
Class :CompanyInfo
Methods :companyName()
Description
You have to overload the method companyName() based on different Number of arguments.
QUESTION 4:
------------
Project :MyPhone
Package :org.phone
Class :Phone
Methods :phoneInfo()
Description
You have to overload the method phoneInfo() based on different datatype order in arguments.
Solution:
package org.myphone.overload;
// different arguments
// increasing length
// changing order
private void phoneinfo(long imei_number, int internal_storage, String
name, String model) {
// TODO Auto-generated method stub
System.out.println("Your phone internal storage is : " +
internal_storage);
System.out.println("Your phone model is : " + model);
System.out.println("Your phone imei number is :" +
imei_number);
System.out.println("Your phone name is : " + name);
}
pi.phoneinfo("Poco");
pi.Phoneinfo("x5 pro");
pi.phoneinfo(256);
pi.phoneinfo(12345678l);
pi.phoneinfo("12 pro", "MI");
pi.phoneinfo("5g", "Moto", 123456l);
pi.phoneinfo(9876545643l, 125, "vivo", "6y");
pi.phoneinfo("moonlight 6", "oppo", 456389272l, 126);
}
}
Result:
QUESTION 5:
-----------
Project :GreensAddress
Package :org.add
Class :GreensTech
Methods :greensOmr()
Description
You have to overload the method greensOmr() based on order,type,number.
Refer to Example program in method overloading class page no : or Program question : 4 (previous
program) only method will be changed as greensomr and will be executed for arguments id, name,
phone number, address etc…
QUESTION 6:
------------
Project :BankDetails
Package :org.bank
Class :BankInfo
Methods :saving(),fixed(),deposit()
Class :AxisBank
Methods :deposit()
Description:
You have to override the method deposit in AxisBank.
Solution 1:
package org.bank.mor;
Solution 2:
package org.bank.mor;
@Override
public void deposit() {
// TODO Auto-generated method stub
System.out.println("deposit 3%");
}
System.out.println();
BankInfo ab=new AxisBank();
ab.saving();
ab.fixed();
ab.deposit();
System.out.println();
BankInfo bi=new BankInfo();
bi.saving();
bi.deposit();
bi.fixed();
}
}
Result:
deposit 3%
savings 1%
fixed 2%
deposit 3%
savings 1%
deposit 5%
fixed 2%
QUESTION 7:
------------
Project :EducationInformation
Package :org.edu
Class :Education
Methods :ug(),pg()
Class :Arts
Methods :bSc(),bEd(),bA(),bBA(),ug(),pg()
Description:
You have to override the method ug(),pg() in Arts.
Solution 1:
package org.edu.mor;
Solution 2:
package org.edu.mor;
@Override
public void ug() {
// TODO Auto-generated method stub
System.out.println("Bachelors");
}
ar.ug();
ar.pg();
ar.ba();
ar.bba();
ar.bed();
ar.bsc();
System.out.println();
ed.ug();
ed.pg();
System.out.println();
Result:
Bachelors
Masters
bachelor of arts
Bachelor of business administration
Bachelor of education
Bachelor of science
Under Graduate
Post Graduate
Masters
Bachelors
Doctrate
QUESTION 8:
------------
Project :UniversityInformation
Package :org.univ
Class :University
Methods :ug(),pg()
Class :College
Methods :ug(),pg()
Description:
ug(),pg() is just a templete in University class and You have to override the method ug(),pg() in
College class.
Solution 1:
package org.univ.mor;
Solution 2:
package org.univ.mor;
public class College extends University {
@Override
public void ug() {
// TODO Auto-generated method stub
System.out.println("Under Graduate");
}
@Override
public void pg() {
// TODO Auto-generated method stub
super.pg();
System.out.println("Post Graduate");
}
cg.ug();
cg.pg();
System.out.println();
uy.ug();
uy.pg();
System.out.println();
uc.ug();
uc.pg();
}
}
Result:
Under Graduate
Masters
Post Graduate
Bachelors
Masters
Under Graduate
Masters
Post Graduate
QUESTION 9:
------------
Project :BikeInformation
Package :org.bike
Interface :Bike
Methods :cost(),speed()
Class :Ktm
Methods :cost(),speed()
Description:
cost(),speed() is just a templete in Bike Interface and You have to override the method cost(),speed()
in Ktm class.
Solution 1:
package org.bike.interfacee;
void cost();
void speed();
}
Solution 2:
package org.bike.interfacee;
@Override
public void cost() {
// TODO Auto-generated method stub
System.out.println("2lakhs");
}
@Override
public void speed() {
// TODO Auto-generated method stub
System.out.println("200km");
}
k.cost();
k.speed();
System.out.println();
bk.cost();
bk.speed();
}
Result:
2lakhs
200km
2lakhs
200km
QUESTION 10:
-------------
Project :Computer
Interface :HardWare
Methods :hardwareResources()
Interface :Software
Methods :softwareResources()
Class :Desktop
Methods :desktopModel()
Description:
create 2 Interface and archieve multiple inheritance.
Solution 1:
package org.comp.multipleinheri.interfa;
void hardwareresources();
void system();
}
Solution 2:
package org.comp.multipleinheri.interfa;
void softwareresources();
void system();
}
Solution 3:
package org.comp.multipleinheri.interfa;
@Override
public void softwareresources() {
// TODO Auto-generated method stub
System.out.println("ram,rom");
}
@Override
public void hardwareresources() {
// TODO Auto-generated method stub
System.out.println("cpu,moniter");
}
@Override
public void system() {
// TODO Auto-generated method stub
System.out.println("hardware and software");
}
dt.softwareresources();
dt.hardwareresources();
dt.system();
System.out.println();
hd.hardwareresources();
hd.system();
System.out.println();
sf.softwareresources();
sf.system();
}
Result:
ram,rom
cpu,moniter
hardware and software
cpu,moniter
hardware and software
ram,rom
hardware and software
QUESTION 1:
------------
package org.test;
}
System.out.println(i);
Result:
1 2 3 4 5 6 7 8 9 10 11 12 13………………………..91 92 93 94 95 96 97 98 99 100
QUESTION 2:
------------
package org.test;
Result:
1234
It breakes the statement when it reaches 5 as per given condition
QUESTION 3:
----------
package org.test;
Result:
1 2 3 4 6 7 8 9 10
QUESTION 4:
------------
package org.test;
Result:
123123123
QUESTION 5:
------------
package org.test;
Result:
111222333
QUESTION 6:
-----------
package org.test;
Result:
112123
QUESTION 7:
-----------
package org.test;
Result:
233
QUESTION 8:
------------
package org.test;
Result:
Executes nothing
QUESTION 9:
------------
package org.test;
Result:
Result:
QUESTIONS(Programs)
-------------------
QUESTION 1:
-----------
Description: Write Java program to allow the user to input his/her age.
Then the program will show if the person is eligible to vote.
A person who is eligible to vote must be older than or equal 1 to 18 years old.
Example:
--------
Input = 10
Output = print not eligible.
package org.javaprograms;
import java.util.Scanner;
v = new Scanner(System.in);
if (Value % 2 == 0) {
System.out.println(Value + " is Even");
} else {
QUESTION 2:
-----------
Description: Write a program to find even or odd number
Example:
---------
Input = 10
Output = Even
package org.javaprograms;
import java.util.Scanner;
int age;
System.out.println("Enter your age");
a = new Scanner(System.in);
age=a.nextInt();
if (age >= 18) {
System.out.println("You are eigible to vote");
} else {
System.out.println("You are not eligible to vote");
}
}
QUESTION 3:
------------
Description: Write a program to print even number from 1 to 100
Example:
---------
Output = 2,4,....100
package org.javaprograms;
2 4 6 8 10………………………90 92 94 96 98 100
QUESTION 4:
------------
Description: Find the sum of odd number 1 to 100
Example:
--------
Output = 2500
package org.javaprograms;
QUESTION 5:
-----------
Description: Count of even number 1 to 100
Example:
--------
Output = 50
package org.javaprograms;
QUESTION 6:
-----------
Description: Write a program to find the factorial of a number.
Example:
--------
Input = 5
Output = 120
package org.javaprograms;
import java.util.Scanner;
s = new Scanner(System.in);
int n = s.nextInt();
int fact = 1;
for (int i = 1; i <= n; i++)
fact = fact * i;
QUESTION 7:
------------
Description: Write a program to print the fibonacci series of a number 1 to 100.
Example:
--------
Output = 0,1,1,2,3,5.....
package org.javaprograms;
int n1 = 0, n2 = 1, sum = 0;
n1 = n2; // 1 1 2 3 5.............
n2 = sum; // 1 2 3 5 8..........
}
}
}
0 1 1 2 3 5 8 13 21 34 55 89
QUESTION 8:
-----------
Description: Find prime number or not.
Example:
--------
Input = 11
Output = prime number
package org.javaprograms;
import java.util.Scanner;
pr = new Scanner(System.in);
int n = pr.nextInt();
int i, m = 0, flag = 0;
// int n = 3;// it is the number to be checked
m = n / 2;
if (n == 0 || n == 1) {
System.out.println(n + " is not prime number");
} else {
for (i = 2; i <= m; i++) {
if (n % i == 0) {
System.out.println(n + " is not prime
number");
flag = 1;
break;
}
}
if (flag == 0) {
System.out.println(n + " is prime number");
}
} // end of else
}
}
QUESTION 9:
-----------
Description : Print the below patterns using for loop.
Output:
-------
1
12
123
1234
12345
123456
1234567
-----------------------
package org.patternprograms;
*
* *
* * *
* * * *
* * * * *
--------------------------
package org.patternprograms;
*
* *
* * *
* * * *
* * * * *
* * * * * *
*
**
***
****
*****
-----------------------------
package org.patternprograms;
*
* *
* * *
* * * *
* * * * *
* * * * * *
QUESTION 10:
-------------
Description: Find Amstrong number or not
Example:
--------
Input = 153
Output = Amstrong number
package org.javaprograms;
import java.util.Scanner;
import java.lang.Math;
// driver code
public static void main(String args[]) {
int num;
sc = new Scanner(System.in);
System.out.print("Enter the number: ");
// reads the limit from the user
num = sc.nextInt();
if (isArmstrong(num)) {
System.out.print("Armstrong ");
} else {
System.out.print("Not Armstrong ");
}
}
}
QUESTION 11:
-------------
Description: Reverse the number
Example:
--------
Input = 123
Output = 321
package org.javaprograms;
import java.util.Scanner;
rn = new Scanner(System.in);
System.out.println("Enter the number : ");
int number=rn.nextInt();
//int number = 987654,
int reverse = 0;
while (number != 0) {
int remainder = number % 10;
reverse = reverse * 10 + remainder;
number = number / 10;
}
System.out.println("The reverse of the given number is: " +
reverse);
}
}
QUESTION 12:
-------------
Description: Count of the number
Example:
--------
Input = 123
Output = 3
package org.javaprograms;
import java.util.Scanner;
c = new Scanner(System.in);
int num=c.nextInt();
int count=0;
while (num != 0) {
num /= 10;
count++;
QUESTION 13:
-------------
Description: Sum of the number
Example:
--------
Input = 123
Output = 6
package org.javaprograms;
import java.util.Scanner;
sn = new Scanner(System.in);
int sum=0;
while(n>0)
{
sum=sum+n%10; // 6+5+4+3+2+1
n=n/10;//12345 1234 123 12 1 0
}
System.out.println("Sum of digits in a nu ber is : " + sum);
QUESTION 14:
--------------
Description: Verify the number is palindrome number not
Example:
--------
Input = 141
Output = Palindrome
package org.javaprograms;
import java.util.Scanner;
p = new Scanner(System.in);
int sum=0;
int temp;
int r;
temp=n;
while (n>0) {
r=n%10;
sum=(sum*10)+r;
n=n/10;
}
if (temp==sum)
System.out.println("Palindrome");
else
System.out.println("Not a Palindrome");
}
}
Additional Program
Palindrome of a string
Solution:
package org.javaprograms;
import java.util.Scanner;
ps = new Scanner(System.in);
System.out.println("Enter a word : ");
if (str.toLowerCase().equals(reverseStr.toLowerCase())) {
System.out.println(str + " is a Palindrome String.");
} else {
System.out.println(str + " is not a Palindrome String.");
}
}
}
Result:
Enter a word :
MALAYALAM
MALAYALAM is a Palindrome String.
----------------------------
QUESTION 1:
-------------
package org.test;
public class A {
public A() {
this("JAVA");
System.out.println("Default const...");
this(3456.5678f);
System.out.println(id);
}
public A(String name) {
this(12);
System.out.println(name);
System.out.println(sal);
A a = new A();
Result:
3456.5679
12
JAVA
Default const...
QUESTION 2:
-----------
package org.test;
public A() {
System.out.println("Default const...");
package org.test;
public class B {
public B() {
System.out.println("Super class");
Result:
Super class
Default const...
QUESTION 3:
------------
package org.test;
public A() {
System.out.println("Default const...");
A a = new A();
}
}
package org.test;
public class B {
public B() {
System.out.println("Super class");
System.out.println(id);
Result:
Super class
Default const...
QUESTION 4:
------------
package org.test;
public A() {
super(12);
System.out.println("Default const...");
A a = new A();
}
}
package org.test;
public class B {
public B() {
System.out.println("Super class");
System.out.println(id);
QUESTION 5:
-----------
package org.test;
public class B {
System.out.println(id);
package org.test;
super(12);
System.out.println("Default const...");
A a = new A();
Result:
12
Default const...
QUESTION 6:
------------
package org.test;
public A() {
System.out.println("Default const...");
A a = new A();
package org.test;
public class B {
System.out.println(id);
Result:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Implicit super constructor B() is undefined. Must explicitly invoke
another constructor
at org.test.day4assignment.A.<init>(A.java:4)
at org.test.day4assignment.A.main(A.java:10)
SELENIUM
ASSIGNMENT/INTERVIEW QUESTIONS SELENIUM – 1.1(Theory)
------------------
4.What is the difference between Selenium IDE, Selenium RC, and WebDriver?
5.What is the latest version of selenium jar file and how you will configure selenium jar file with
eclipse?
1.Firefox browser
2.Chrome browser
3.IE
4.safari browser
5.Opera browser
-------------------------------------------
2.Facebook - https://www.facebook.com/
3.Amazon - https://www.amazon.in
4.Greens technologys-http://greenstech.in/selenium-course-content.html
package org.selenium.assignments.day1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("Webdriver.gecko.driver",
"C:\\Users\\91636\\New eclipse - workspace\\
Selenium_Assignments\\DriverFiles\\chromedriver.exe");
driver.get("http://www.greenstechnologys.com/");
driver.get("http://gmail.com/");
driver.get("http://www.flipkart.com/");
driver.get("http://greenstech.in/selenium-course-
content.html");
driver.quit();
}
------------------------------------------
2.Gmail - http://gmail.com/
3.Flipkart - http://www.flipkart.com/
4.Greens technology-http://greenstech.in/selenium-course-content.html
package org.selenium.assignments.day1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("Webdriver.gecko.driver",
"C:\\Users\\91636\\New eclipse - workspace\\
Selenium_Assignments\\DriverFiles\\chromedriver.exe");
driver.get("http://www.greenstechnologys.com/");
driver.get("http://gmail.com/");
driver.get("http://www.flipkart.com/");
driver.get("http://greenstech.in/selenium-course-
content.html");
driver.quit();
}
}
The above urls will get launched and closed
--------------------------------------
package org.selenium.assignments.day1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
System.setProperty("Webdriver.gecko.driver",
"C:\\Users\\91636\\New eclipse - workspace\\
Selenium_Assignments\\DriverFiles\\msedgedriver.exe");
driver.get("http://www.greenstechnologys.com/");
driver.get("http://demo.automationtesting.in/Register.html");
driver.get("http://www.greenstechnologys.com/");
driver.get("http://greenstech.in/selenium-course-
content.html");
driver.quit();
}