0% found this document useful (0 votes)
72 views85 pages

ASSIGNMENT Questions Course

Uploaded by

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

ASSIGNMENT Questions Course

Uploaded by

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

ASSIGNMENT/INTERVIEW QUESTIONS – 1.

1(Theory):
------------

1.What is platform independent?

The meaning of Java platform-independent is that the Java compiled code(byte code) can run on
all operating systems.

2.What is open source?

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.

3.Difference between JDK,JRE,JVM?

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.

The JVM performs the following main tasks:


Loads code
Verifies code
Executes code
Provides runtime environment

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.

4.why we go for java?

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

7.Difference between c++ and java?

C++ Java

C++ is designed to work with compiler only Java can support both compiler and interpreter

Platform dependent Platform independent

C++ uses “cin” and “cout” Complex in/out methods (System.in and System.out)

Incorporates backward compatibility with C No backward compatibility support

C++ is a combination of OOPs and Procedural type of


Supports only Object-Oriented Programming style
programming

Memory management is manual, and the user is


JVM manages memory without user intervention
responsible for the memory consumed

C++ can provide multiple inheritances Java cannot support multiple inheritances

C++ supports both method overloading and operator


Java supports only method overloading
overloading

Source code is not portable between different operating


Source code is portable to any operating system
systems

Libraries offer low-level of functionality Libraries offer high-level functionality

The programmer is responsible for run-time errors and


JVM is responsible for run-time errors and exceptions
exceptions
C++ supports pointers Java does not have pointers

C++ supports structures (custom data type) Java does not provide structures

C++ supports unions Java does not provide unions

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?

We are using only oxygen eclipse to execute java programms

10.Difference between class,method,object?

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.

11.Where object stores?


Whenever an object is created, it's always stored in the Heap space and stack memory contains the
reference to it. Stack memory only contains local primitive variables and reference variables to
objects in heap space.

12.How to access one class method in to another package in different package?

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.

14.Coding standard to create project,class,method,package and object ?

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.

ASSIGNMENT/INTERVIEW QUESTIONS – 1.2(Programs):


-----------------
QUESTION 1:
------------
Project :EmployeeDetails
Package :org.emp
Class :Employee
Methods :empId(),empName(),empDob(),empPhone(),empEmail(),empAddress()

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 {

//method name = control + space


private void employeeid() {

// TODO Auto-generated method stub


//sysout ---- control + space

System.out.println("Employee id number is 1");

}
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 employeephone() {


// TODO Auto-generated method stub
System.out.println("Employee phone number is 6369793294");

}
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");

//main -------- control + space


public static void main(String[] args) {
//object creation
//classname objectname=new classname
Employee e=new Employee();

//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 class GreensTech_1 {

//method name = control + space


public void greensomr() {

// TODO Auto-generated method stub

//sysout ---- control + space


System.out.println("OMR,\r\n" +
"11 First Street Padmanabha Nagar,\r\n" +
"Chennai\r\n" +
"Tel: +91- 72005 52296");

}
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;

public class GreenTech_2 {


public void phonenumber_tambaram() {
// TODO Auto-generated method stub
System.out.println("9784562234");
}
public void phonenumber_adayar() {
// TODO Auto-generated method stub
System.out.println("9784562234");
}
public void phonenumber_velachery() {
// TODO Auto-generated method stub
System.out.println("9784562234");
}
public static void main(String[] args) {
GreenTech_2 GT2=new GreenTech_2();
GT2.phonenumber_tambaram();
GT2.phonenumber_adayar();
GT2.phonenumber_velachery();

}
}

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");

private void companyaddress() {


// TODO Auto-generated method stub
System.out.println("Company address is no.2,3RD
STREET,Tambaram");

}
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()

GreensTech_1 g=new GreensTech_1();

//method calling
//object name.methodname
g.greensomr();
g.greensadayar();
g.greensannanagar();
g.greenstambaram();
g.greensvelachery();

GreenTech_2 GT2=new GreenTech_2();


GT2.phonenumber_tambaram();
GT2.phonenumber_adayar();
GT2.phonenumber_velachery();
}
}

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

public class PhoneInfo {

//method name = control + space


private void phoneid() {
// TODO Auto-generated method stub
System.out.println("Employee id is 1");

}
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");

public static void main(String[] args) {


//object creation
//classname objectname=new classname
PhoneInfo pi=new PhoneInfo();

//method calling
//object name.methodname
pi.camera();
pi.osname();
pi.phoneid();
pi.phonename();
pi.storage();
//phoneName(),phoneMieiNum(),Camera(),storage(),osName()
}
}

Result:

Front camera 16pixelback camera 120 mega pixel


Android
Employee id is 1
Employee name is Poco x5 pro
Internal 120gb expandable upto 256gb

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;

public class LanguageInfo {

public void tamillanguage() {


// TODO Auto-generated method stub
System.out.println("Vanakkam");
}

public void englishlanguage() {


// TODO Auto-generated method stub
System.out.println("Hello");
}

public void hindilanguage() {


// TODO Auto-generated method stub
System.out.println("Namasthe");
}

public static void main(String[] args) {

LanguageInfo LA=new LanguageInfo();

LA.englishlanguage();
LA.tamillanguage();
LA.hindilanguage();

StateDetails SD=new StateDetails();

SD.southIndia();
SD.northIndia();

}
}

Result 1:

Hello
Vanakkam
Namasthe

Solution 2:

package org.lang;
public class StateDetails {

public void southIndia() {


// TODO Auto-generated method stub
System.out.println("Tamil Nadu");
}

public void northIndia() {


// TODO Auto-generated method stub
System.out.println("Delhi");
}

public static void main(String[] args) {

StateDetails SD=new StateDetails();

SD.southIndia();
SD.northIndia();

LanguageInfo LA=new LanguageInfo();

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;

public class Client {


public void clientname() {
// TODO Auto-generated method stub
System.out.println("Client name is HCL");
}

public static void main(String[] args) {


Client CLN=new Client();

CLN.clientname();
}
}

Result 1:

Client name is HCL

Solution 2:

package org.company;

import org.client.Client;
import org.emp2.Employee;
import org.project.Project;

public class Company {


public void companyname() {
// TODO Auto-generated method stub
System.out.println("Company name is GT");
}

public static void main(String[] args) {

// TODO Auto-generated method stub

Company CN=new Company();


CN.companyname();

}
}

Result 2:

Company name is GT
Solution 3:

package org.project;

public class Project {


public void projectname() {
// TODO Auto-generated method stub
System.out.println("Project name is email");
}
public static void main(String[] args) {

Project pn=new Project();

pn.projectname();
}
}

Result 3:

Project name is email

Solution 4:

package org.emp;

import org.client.Client;
import org.company.Company;
import org.project.Project;

public class Employee {


public void employeename() {
// TODO Auto-generated method stub
System.out.println("Employee Name is Vasanth");
}
public static void main(String[] args) {
Employee E=new Employee();

E.employeename();

Company CN=new Company();


CN.companyname();

Client CLN=new Client();


CLN.clientname();

Project pn=new Project();


pn.projectname();
}
}

Result 4:

Employee Name is Vasanth


Company name is GT
Client name is HCL
Project name is email
QUESTION 7:
-------------
Project :PhoneDetails
Package :org.phone
Class :ExternalStorage
Methods :size()

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;

public class External_Storage {


public void size() {
// TODO Auto-generated method stub
System.out.println("256gb");
}
public static void main(String[] args) {
External_Storage es=new External_Storage();

es.size();
}
}

Result 1:

256gb

Solution 2:

package org.phone;

public class Internal_Storage {


private void processorname() {
// TODO Auto-generated method stub
System.out.println("Snapdragon");
}
private void internalstorage() {
// TODO Auto-generated method stub
System.out.println("128gb");
}
public static void main(String[] args) {
Internal_Storage IS=new Internal_Storage();

IS.internalstorage();
IS.processorname();

External_Storage es=new External_Storage();


es.size();
}
}

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;

public class College {


public void college_name() {
// TODO Auto-generated method stub
System.out.println("SSIET");
}
public void college_code() {
// TODO Auto-generated method stub
System.out.println("2124");
}
public void college_rank() {
// TODO Auto-generated method stub
System.out.println("12");
}
public static void main(String[] args) {
College C1=new College();

C1.college_code();
C1.college_name();
C1.college_rank();

Student S1=new Student();


S1.student_id();
S1.student_name();
S1.student_dep();

Department D=new Department();

D.dept_name();

Hostel H=new Hostel();

H.hostel_name();
}
}

Result 1:

2124
SSIET
12
21
Vasanth
ECE
ECE
VIVEKANANDHA

Solution 2:

package org.college;

public class Department {


public void dept_name() {
// TODO Auto-generated method stub
System.out.println("ECE");
}
public static void main(String[] args) {
Department D=new Department();

D.dept_name();
}
}

Result 2:

ECE

Solution 3:

package org.college;

public class Hostel {


public void hostel_name() {
// TODO Auto-generated method stub
System.out.println("VIVEKANANDHA");
}
public static void main(String[] args) {
Hostel H=new Hostel();
H.hostel_name();
}
}

Result 3:

VIVEKANANDHA

Solution 4:

package org.college;

public class Student {


public void student_name() {
// TODO Auto-generated method stub
System.out.println("Vasanth");

public void student_id() {


// TODO Auto-generated method stub
System.out.println("21");
}

public void student_dep() {


// TODO Auto-generated method stub
System.out.println("ECE");
}
public static void main(String[] args) {
Student S1=new Student();

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;

public class Vehicle {


private void vehicle_necessary() {
// TODO Auto-generated method stub
System.out.println("Bike");
}
public static void main(String[] args) {
Vehicle V1=new Vehicle();

V1.vehicle_necessary();

Twowheeler TW=new Twowheeler();

TW.bike();
TW.cycle();

Threewheeler THW=new Threewheeler();

THW.auto();

Fourwheeler FW=new Fourwheeler();

FW.car();
FW.bus();
FW.lorry();
}
}

Result 1:

Bike
honda
hero
pd
bmw
volvo
tata

Solution 2:
package org.fourwheeler;

public class Fourwheeler {


public void car() {
// TODO Auto-generated method stub
System.out.println("bmw");
}
public void bus() {
// TODO Auto-generated method stub
System.out.println("volvo");
}
public void lorry() {
// TODO Auto-generated method stub
System.out.println("tata");
}

public static void main(String[] args) {


Fourwheeler FW=new Fourwheeler();

FW.car();
FW.bus();
FW.lorry();
}
}

Result 2:

bmw
volvo
tata

Solution 3:

package org.threewheeler;

public class Threewheeler {


public void auto() {
// TODO Auto-generated method stub
System.out.println("pd");
}
public static void main(String[] args) {
Threewheeler THW=new Threewheeler();

THW.auto();
}
}

Result 3:

Pd

Solution 4:

package org.twowheeler;

public class Twowheeler {


public void bike() {
// TODO Auto-generated method stub
System.out.println("honda");
}
public void cycle() {
// TODO Auto-generated method stub
System.out.println("hero");
}
public static void main(String[] args) {
Twowheeler TW=new 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;

public class Air {


public void aeroplane() {
// TODO Auto-generated method stub
System.out.println("airlines");
}
public void helicopter() {
// TODO Auto-generated method stub
System.out.println("military");
}
public static void main(String[] args) {
Air ar=new Air();

ar.aeroplane();
ar.helicopter();
}
}

Result 1:

airlines
military

Solution 2:

package org.road;

public class Road {


public void bus() {
// TODO Auto-generated method stub
System.out.println("BMW-1 "+"AUDI-2");
}
public void car() {
// TODO Auto-generated method stub
System.out.println("tata-3 "+"hyundai-5");
}
public void bike() {
// TODO Auto-generated method stub
System.out.println("yamaha-6 "+"pulsar-4");
}
public void cycle() {
// TODO Auto-generated method stub
System.out.println("hero-3 "+"bird-6");
}
public static void main(String[] args) {
Road rd=new 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;

public class Water {


public void boat() {
// TODO Auto-generated method stub
System.out.println("titanic");
}
public void ship() {
// TODO Auto-generated method stub
System.out.println("cruise");
}
public static void main(String[] args) {
Water wr=new Water();
wr.boat();
wr.ship();
}
}

Result 3:

titanic
cruise

Solution 4:

package org.transport;

import org.air.Air;
import org.road.Road;
import org.water.Water;

public class Transport {


public void transportform() {
// TODO Auto-generated method stub
System.out.println("three");
}
public static void main(String[] args) {
Transport tt=new Transport();

tt.transportform();
Road rd=new Road();

rd.bike();
rd.bus();
rd.car();
rd.cycle();

Air ar=new Air();

ar.aeroplane();
ar.helicopter();

Water wr=new Water();


wr.boat();
wr.ship();

}
}

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;

public class Lan {


public void lanname() {
// TODO Auto-generated method stub
System.out.println("bsnl");
}
public static void main(String[] args) {
Lan lan=new Lan();

lan.lanname();
}
}

Result 1:

Bsnl

Solution 2:
package org.network;

public class Mobile_data {


public void dataname() {
// TODO Auto-generated method stub
System.out.println("jio");
}
public static void main(String[] args) {
Mobile_data MD=new Mobile_data();

MD.dataname();
}
}

Result 2:

Jio

Solution 3:
package org.network;

public class Wireless {


public void modemname() {
// TODO Auto-generated method stub
System.out.println("airtel");
}
public static void main(String[] args) {
Wireless wl=new Wireless();

wl.modemname();
}
}

Result 3:

airtel

Solution 4:
package org.network;

public class Wifi {


public void wifiname() {
// TODO Auto-generated method stub
System.out.println("ACE");
}
public static void main(String[] args) {
Wifi wf=new Wifi();

wf.wifiname();

Mobile_data MD=new Mobile_data();

MD.dataname();

Lan lan=new Lan();

lan.lanname();
Wireless wl=new Wireless();

wl.modemname();
}
}

Result 4:

ACE
jio
bsnl
airtel

ASSIGNMENT/INTERVIEW QUESTIONS – 2.1(Theory)


--------------

1.What is mean by inheritance?


2.Types of inheritance and explain all types?
3.What is mean by multiple inheritance,why java won't support multiple inheritance?
4.Difference between hybrid and hierachical inheritance?
5.What is the use of access specifier and types?
6.Difference between public and protected?
7.What is mean by Wrapper class?
8.What is default value of String?
9.What is difference between primitive and non primitive datatypes?
10.What is default package in java?
11.What is the super class of all java class?
12.What is use of scanner class?
13.What are the different methods available in Scanner class?
14.Scanner class is under which package?
15.Difference between next() and nextLine()?

ASSIGNMENT/INTERVIEW QUESTIONS – 2.2(Programs)


--------------------
QUESTION 1:
------------
Description: Using Scanner class get the below details
empId
empName
empEmail
empPhoneno
empSalary
empGender
empCity

Refer to Example program in scanner class page no : it is same as this problem


QUESTION 2:
-------------
Description: Using Scanner class get the below details
studentId
studentName
Mark1
Mark2
Mark3
Mark4
Mark5
:Find the total and average of marks

Solution:

package org.student.details.scanner;

import java.util.Scanner;

public class Student_Details_Scr {

private static Scanner sD;


private static Scanner sd1;

public static void main(String[] args) {

sD = new Scanner(System.in);
sd1 = new Scanner(System.in);

System.out.println("Enter your id :");


int studentid=sD.nextInt();
System.out.println("Your id is : " + studentid);

System.out.println("Enter your name :");


String name=sd1.nextLine();
System.out.println("Your name is : " + name);

System.out.println("Enter your mark1 :");


float mark1=sD.nextFloat();
System.out.println("Your Mark1 is " + mark1);

System.out.println("Enter your mark2 :");


float mark2=sD.nextFloat();
System.out.println("Your Mark2 is " + mark2);

System.out.println("Enter your mark3 :");


float mark3=sD.nextFloat();
System.out.println("Your Mark3 is " + mark3);

System.out.println("Enter your mark4 :");


float mark4=sD.nextFloat();
System.out.println("Your Mark4 is " + mark4);

System.out.println("Enter your mark5 :");


float mark5=sD.nextFloat();
System.out.println("Your Mark5 is " + mark5);
float totalmark = mark1+mark2+mark3+mark4+mark5;
System.out.println("Your total mark is : " + totalmark);

float averagemark = totalmark/5;


System.out.println("Your average mark is : " + averagemark);

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

package name: org.tamil


Project name: LanguageDetails
Class name : Tamil
Methods : tamillanguage

package name: org.english


Project name: LanguageDetails
Class name : English
Methods : englishlanguage

package name: org.telgu


Project name: LanguageDetails
Class name : Telgu
Methods : telgulanguage

Description:
create above 4 packages and call all your class methods into the Languageclass using multilevel
inheritance.

Solution 1:

package org.english;

public class English {

public void englishlanguage() {


// TODO Auto-generated method stub
System.out.println("Hello");

}
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 {

public void telugulanguage() {


// TODO Auto-generated constructor stub
System.out.println("NAMASKARAM");
}
public static void main(String[] args) {
Telugu TG=new Telugu();

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 {

private void alllanguage() {


// TODO Auto-generated method stub
System.out.println("helloha");
}
public static void main(String[] args) {
Languageclass LC=new Languageclass();

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

package name: org.kerala


Project name: SouthIndia
Class name : kerala
Methods : malayalam

package name: org.andrapradesh


Project name: SouthIndia
Class name : AndhraPradesh
Methods : telugu

Description:
create above 4 packages and call all your class methods into the India using multilevel inheritance.

Solution 1:

package org.andhra;

public class Andhra {


public void telugu() {
// TODO Auto-generated method stub
System.out.println("Namaskaram");
}
public static void main(String[] args) {
Andhra AP=new Andhra();

AP.telugu();
}

Result 1:

Namaskaram

Solution 2:

package org.kerala;

import org.andhra.Andhra;

public class Kerala extends Andhra {


public void malayalam() {
// TODO Auto-generated method stub
System.out.println("swagatham");
}
public static void main(String[] args) {
Kerala KL=new Kerala();

KL.malayalam();
KL.telugu();
}
}

Result 2:

swagatham
Namaskaram

Solution 3:

package org.tamilnadu;

import org.kerala.Kerala;

public class TamilNadu extends Kerala {


public void tamillanguage() {
// TODO Auto-generated method stub
System.out.println("VANAKKAM");
}
public static void main(String[] args) {
TamilNadu TN=new TamilNadu();

TN.tamillanguage();
TN.telugu();
TN.malayalam();
}
}

Result 3:

VANAKKAM
Namaskaram
Swagatham

Solution 4:

package org.s.india;

import org.tamilnadu.TamilNadu;

public class Sindia extends TamilNadu {


public void southindia() {
// TODO Auto-generated method stub
System.out.println("TAK");
}
public static void main(String[] args) {
Sindia SI=new Sindia();

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;

public class Hostel {


public void hostelname() {
// TODO Auto-generated method stub
System.out.println("Vivekanandha");
}
public static void main(String[] args) {
Hostel HL=new Hostel();

HL.hostelname();
}
}

Result 1:

Vivekanandha

Solution 2:

package org.college;

public class Dept extends Hostel {


public void deptname() {
// TODO Auto-generated method stub
System.out.println("ece");
}
public static void main(String[] args) {
Dept DT=new Dept();
DT.deptname();
DT.hostelname();
}
}

Result 2:

ece
Vivekanandha

Solution 3:

package org.college;

public class Student extends Dept {


public void studentname() {
// TODO Auto-generated method stub
System.out.println("Vasanth");
}
public void studentdept() {
// TODO Auto-generated method stub
System.out.println("ECE");
}
public void studentid() {
// TODO Auto-generated method stub
System.out.println("1");
}
public static void main(String[] args) {
Student SD=new Student();

SD.studentname();
SD.studentid();
SD.studentdept();

SD.hostelname();
SD.deptname();

}
}

Result 3:

Vasanth
1
ECE
Vivekanandha
ece

Solution 4:

package org.college;

public class College extends Student {


public void collegename() {
// TODO Auto-generated method stub
System.out.println("SSIET");
}
public void collegecode() {
// TODO Auto-generated method stub
System.out.println("2124");
}
public void collegerank() {
// TODO Auto-generated method stub
System.out.println("21");
}
public static void main(String[] args) {
College CG=new 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;

public class Computer_SI {

private void computermodel() {


// TODO Auto-generated method stub
System.out.println("Apple");
}

public static void main(String[] args) {

Computer_SI cm=new Computer_SI();

cm.computermodel();
}
}

Result 1:

Apple

Solution 2:

package org.computer.singleinheritance;

public class Desktop_SI extends Computer_SI {

private void desktopsize() {


// TODO Auto-generated method stub
System.out.println("500gb");
}

public static void main(String[] args) {

Desktop_SI dt=new Desktop_SI();

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 class LanguageInfo_2 extends StateDetails {


public void tamillanguage() {
// TODO Auto-generated method stub
System.out.println("Vanakam");
}
public void englishlanguage() {
// TODO Auto-generated method stub
System.out.println("hello");
}
public void hindilanguage() {
// TODO Auto-generated method stub
System.out.println("Namaste");

}
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;

public class Bankinfo {

public void saving() {


// TODO Auto-generated method stub
System.out.println("saving account bal: 2000");
}

public void fixed() {


// TODO Auto-generated method stub
System.out.println("fixed balence: 100000");
}

public static void main(String[] args) {

Bankinfo bi = new Bankinfo();

bi.saving();
bi.fixed();
}
}
Result 1:

saving account bal: 2000


fixed balence: 100000

Solution 2:

package org.bank.si;

public class AxisBank extends Bankinfo {


private void deposit() {
// TODO Auto-generated method stub
System.out.println("Deposit intrest is : 4%");
}

public static void main(String[] args) {

AxisBank ab = new AxisBank();

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;

public class Companysi {

public void companyname() {


// TODO Auto-generated method stub
System.out.println("HCL");
}
public static void main(String[] args) {

Companysi csi = new Companysi();

csi.companyname();

}
}

Result 1:

HCL

Solution 2:

package org.client.si;

import org.company.si.Companysi;

public class Clientsi extends Companysi {


private void clientname() {
// TODO Auto-generated method stub
System.out.println("GT");
}

public static void main(String[] args) {

Clientsi cli = new Clientsi();

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;

public class Arts {

public void bsc() {


// TODO Auto-generated method stub
System.out.println("Bachelor of science");
}

public void b_ed() {


// TODO Auto-generated method stub
System.out.println("Bachelor of education");
}

public void bba() {


// TODO Auto-generated method stub
System.out.println("Bachelor of Business Administration");
}

public void ba() {


// TODO Auto-generated method stub
System.out.println("Bachelor of Arts");
}

public static void main(String[] args) {

Arts ar = new Arts();

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;

public class Engineering extends Arts {

public void be() {


// TODO Auto-generated method stub
System.out.println("Bachelor of Engineering");
}
public void b_tech() {
// TODO Auto-generated method stub
System.out.println("Bachelor of technology");
}

public static void main(String[] args) {

Engineering eng = new Engineering();

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;

public class Medicine extends Engineering {

public void physiyo() {


// TODO Auto-generated method stub
System.out.println("Bachelor of physiyo");
}

public void dental() {


// TODO Auto-generated method stub
System.out.println("Bachelor of Dental Surgery");
}

public void mbbs() {


// TODO Auto-generated method stub
System.out.println("Bachelor of medicine and Bachelor of
surgery");
}

public static void main(String[] args) {

Medicine med = new Medicine();

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;

public class Education extends Medicine {

public void ug() {


// TODO Auto-generated method stub
System.out.println("Under Graduate");
}

public void pg() {


// TODO Auto-generated method stub
System.out.println("Post Graduate");
}

public static void main(String[] args) {

Education edu = new Education();

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

ASSIGNMENT/INTERVIEW QUESTIONS 3.1(Theory)


--------------------

1.What is mean by polymorphism?


2.Difference between method overloading and method overriding?
3.What is mean by Abstraction?
4.Difference between Abstract class and interface?
5.What is mean by abstract method?
6.Can we create object for abstract class?
7.In interface,can we make method as static?
8.In interface,can we make method as final?
9.How will achieve multiple inheritance in java,write a code for that?

ASSIGNMENT/INTERVIEW QUESTIONS 3.2(Programs)


--------------------

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.

Refer to Example program in method overloading class page no :

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.

Refer to Example program in method overloading class page no :

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;

public class Phone_OL {

// different arguments

private void Phoneinfo(String model) {


// TODO Auto-generated method stub
System.out.println("your phone model : " + model);

private void phoneinfo(String name) {


// TODO Auto-generated method stub
System.out.println("Your phone name : " + name);

private void phoneinfo(long imei_number) {


// TODO Auto-generated method stub
System.out.println("your phone IMEI Number : " + imei_number);

private void phoneinfo(int internal_storage) {


// TODO Auto-generated method stub
System.out.println("your phone internal storage in gb : " +
internal_storage);

// increasing length

private void phoneinfo(String model, String name) {


// TODO Auto-generated method stub
System.out.println("your phone model : " + model + "\nYour
phone name : " + name);

private void phoneinfo(String model, String name, long imei_number) {


// TODO Auto-generated method stub
System.out.println("Your phone imei_number is : " +
imei_number);

private void phoneinfo(String model, String name, long imei_number,


int internal_storage) {
// 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);
}

// 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);
}

public static void main(String[] args) {


Phone_OL pi = new Phone_OL();

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:

Your phone name : Poco


your phone model : x5 pro
your phone internal storage in gb : 256
your phone IMEI Number : 12345678

your phone model : 12 pro


Your phone name : MI
Your phone imei_number is : 123456

Your phone internal storage is : 125


Your phone model is : 6y
Your phone imei number is :9876545643
Your phone name is : vivo

Your phone internal storage is : 126


Your phone model is : moonlight 6
Your phone imei number is :456389272
Your phone name is : oppo

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;

public class BankInfo {

public void saving() {


// TODO Auto-generated method stub
System.out.println("savings 1%");
}

public void fixed() {


// TODO Auto-generated method stub
System.out.println("fixed 2%");
}

public void deposit() {


// TODO Auto-generated method stub
System.out.println("deposit 5%");
}
}

Solution 2:

package org.bank.mor;

public class AxisBank extends BankInfo {

@Override
public void deposit() {
// TODO Auto-generated method stub

System.out.println("deposit 3%");
}

public static void main(String[] args) {

AxisBank ax=new AxisBank();


ax.deposit();

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;

public class Education {

public void ug() {


// TODO Auto-generated method stub
System.out.println("Under Graduate");
}

public void pg() {


// TODO Auto-generated method stub
System.out.println("Post Graduate");
}

public void phd() {


// TODO Auto-generated method stub
System.out.println("Doctrate");
}
}

Solution 2:

package org.edu.mor;

public class Arts extends Education {

@Override
public void ug() {
// TODO Auto-generated method stub
System.out.println("Bachelors");
}

public void pg() {


// TODO Auto-generated method stub
System.out.println("Masters");
}

public void bsc() {


// TODO Auto-generated method stub
System.out.println("Bachelor of science");
}

public void bed() {


// TODO Auto-generated method stub
System.out.println("Bachelor of education");
}

public void ba() {


// TODO Auto-generated method stub
System.out.println("bachelor of arts");
}

public void bba() {


// TODO Auto-generated method stub
System.out.println("Bachelor of business administration");
}

public static void main(String[] args) {


Arts ar = new Arts();

ar.ug();
ar.pg();
ar.ba();
ar.bba();
ar.bed();
ar.bsc();

System.out.println();

Education ed = new Education();

ed.ug();
ed.pg();

System.out.println();

Education ea = new Arts();


ea.pg();
ea.ug();
ea.phd();
}
}

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;

public class University {

public void ug() {


// TODO Auto-generated method stub
System.out.println("Bachelors");
}

public void pg() {


// TODO Auto-generated method stub
System.out.println("Masters");
}
}

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");
}

public static void main(String[] args) {

College cg = new College();

cg.ug();
cg.pg();

System.out.println();

University uy = new University();

uy.ug();
uy.pg();

System.out.println();

University uc = new College();

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;

public interface Bike {

void cost();

void speed();
}

Solution 2:

package org.bike.interfacee;

public class Ktm implements Bike {

@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");
}

public static void main(String[] args) {

Ktm k = new Ktm();

k.cost();
k.speed();

System.out.println();

Bike bk = new Ktm();

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;

public interface Hardware {

void hardwareresources();

void system();
}

Solution 2:

package org.comp.multipleinheri.interfa;

public interface Software {

void softwareresources();

void system();
}

Solution 3:

package org.comp.multipleinheri.interfa;

public class Desktop implements Hardware, Software {

@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");
}

public static void main(String[] args) {

Desktop dt = new Desktop();

dt.softwareresources();
dt.hardwareresources();
dt.system();

System.out.println();

Hardware hd = new Desktop();

hd.hardwareresources();
hd.system();

System.out.println();

Software sf = new Desktop();

sf.softwareresources();
sf.system();
}

Result:

ram,rom
cpu,moniter
hardware and software

cpu,moniter
hardware and software

ram,rom
hardware and software

ASSIGNMENT/INTERVIEW QUESTIONS – 4.1(Theory)


------------------

1.What is difference between break and continue?


2.Whether we can use continue statement in switch?
3.What is mean by control statments and types?
4.What is mean by for loop?
5.Can you explain about for loop execution process?
6.What is difference between while and do-while?
7.What is the use of default keyword in switch?
8.Difference between for and while loop?

ASSIGNMENT/INTERVIEW QUESTIONS – 4.2(Find The Output)


-----------------------

QUESTION 1:
------------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
if (i == 5) {

}
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

It prints from 1 to 100 continuously as no specific action is given to perform

QUESTION 2:
------------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
if (i == 5) {
break;
}
System.out.println(i);

Result:
1234
It breakes the statement when it reaches 5 as per given condition

QUESTION 3:
----------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
if (i == 5) {
continue;
}
System.out.println(i);

Result:

1 2 3 4 6 7 8 9 10

Skips 5 and continues to run the program

QUESTION 4:
------------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
System.out.println(j);
}

Result:

123123123

QUESTION 5:
------------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
System.out.println(i);
}

Result:

111222333

QUESTION 6:
-----------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= i; j++) {
System.out.println(j);
}

Result:

112123

QUESTION 7:
-----------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 3; i++) {
for (int j = i + 1; j <= 3; j++) {
System.out.println(j);
}
}

Result:

233

QUESTION 8:
------------
package org.test;

public class Hello {


public static void main(String[] args) {
for (int i = 1; i <= 3; i++) {
for (int j = i + 1; j <= i; j++) {
System.out.println(j);
}

Result:

Executes nothing

QUESTION 9:
------------
package org.test;

public class Hello {


public static void main(String[] args) {
int i=5;
if (i == 5) {
break;
}
System.out.println(i);
}

Result:

Error occurs as follows

Exception in thread "main" java.lang.Error: Unresolved compilation problem:


break cannot be used outside of a loop or a switch
QUESTION 10:
------------
package org.test;

public class Hello {


public static void main(String[] args) {
int i=5;
if (i == 5) {
continue;
}
System.out.println(i);
}

Result:

Error occurs as follows

Exception in thread "main" java.lang.Error: Unresolved compilation problem:


continue cannot be used outside of a loop

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;

public class Odd_Even {

private static Scanner v;

public static void main(String[] args) {

System.out.println("Enter the Value");

v = new Scanner(System.in);

int Value = v.nextInt();

if (Value % 2 == 0) {
System.out.println(Value + " is Even");
} else {

System.out.println(Value + " is odd");


}
}

Enter the Value


23
23 is odd

QUESTION 2:
-----------
Description: Write a program to find even or odd number

Example:
---------
Input = 10
Output = Even

package org.javaprograms;

import java.util.Scanner;

public class Voter_age {


private static Scanner a;

public static void main(String[] args) {

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");
}
}

Enter your age


10
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;

public class Even_numbers {

public static void main(String[] args) {

for (int i = 1; i <= 100; i++) {


if (i % 2 == 0) {
System.out.println(i);
}
}
}

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;

public class Odd_Numbers_Sum_and_Count {


int sum = 0;

for (int i = 1; i <= 100; i++)


if (i % 2 != 0)
sum = sum + i;

System.out.println("Total sum of odd numbers from 1 to 100 is :


" + sum);
}
}

Total sum of odd numbers from 1 to 100 is : 2500

QUESTION 5:
-----------
Description: Count of even number 1 to 100

Example:
--------
Output = 50

package org.javaprograms;

public class Even_numbers_and_count {

public static void main(String[] args) {


int count = 0;

for (int i = 1; i <= 100; i++)


if (i % 2 == 0)
count++;

System.out.println("Total count of even numbers from 1 to 100


is : " + count);
}

Total count of even numbers from 1 to 100 is : 50

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;

public class Factorial_of_Number {

private static Scanner s;

public static void main(String[] args) {

s = new Scanner(System.in);

System.out.println("Enter the number : ");

int n = s.nextInt();

int fact = 1;
for (int i = 1; i <= n; i++)
fact = fact * i;

System.out.println("Factorial of given number is : " + fact);


}
}

Enter the number :


5
Factorial of given number is : 120

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;

public class Fibonacci_series {

public static void main(String[] args) {

int n1 = 0, n2 = 1, sum = 0;

System.out.print(n1 + " " + n2);

for (int i = 2; i < 12; i++) {


sum = n1 + n2; //1 1+1=2 1+2=3 2+3=5 3+5=8............
System.out.print(" " + sum); // 1 2 3 5 8..........

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;

public class PrimeExample {


private static Scanner pr;

public static void main(String args[]) {

pr = new Scanner(System.in);

System.out.println("Enter the number to be checked : ");

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
}
}

Enter the number to be checked :


11
11 is prime number

QUESTION 9:
-----------
Description : Print the below patterns using for loop.

Output:
-------
1
12
123
1234
12345
123456
1234567
-----------------------

package org.patternprograms;

public class Numberpattern1 {

public static void main(String args[]) {


int i, j, number, n = 7;
// loop for rows
for (i = 0; i < n; i++) {
number = 1;
// loop for columns
for (j = 0; j <= i; j++) {
// prints num
System.out.print(number + " ");
// incrementing the value of number
number++;
}
// throws the cursor at the next line after printing each
row
System.out.println();
}
}
}
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7

*
* *
* * *
* * * *
* * * * *
--------------------------

package org.patternprograms;

public class PyramidPattern {


public static void main(String args[]) {
// i for rows and j for columns
// row denotes the number of rows you want to print
int i, j, row = 6;
// Outer loop work for rows
for (i = 0; i < row; i++) {
// inner loop work for space
for (j = row - i; j > 1; j--) {
// prints space between two stars
System.out.print(" ");
}
// inner loop for columns
for (j = 0; j <= i; j++) {
// prints star
System.out.print("* ");
}
// throws the cursor in a new line after printing each
line
System.out.println();
}
}
}

*
* *
* * *
* * * *
* * * * *
* * * * * *

*
**
***
****
*****
-----------------------------
package org.patternprograms;

public class Righttriangle_Pattern {

public static void main(String args[]) {


// i for rows and j for columns
// row denotes the number of rows you want to print
int i, j, row = 6;
// outer loop for rows
for (i = 0; i < row; i++) {
// inner loop for columns
for (j = 0; j <= i; j++) {
// prints stars
System.out.print("* ");
}
// throws the cursor in a new line after printing each
line
System.out.println();
}
}
}

*
* *
* * *
* * * *
* * * * *
* * * * * *

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;

public class ArmstsrongNumberExample {


private static Scanner sc;

// function to check if the number is Armstrong or not


static boolean isArmstrong(int n) {
int temp, digits = 0, last = 0, sum = 0;
// assigning n into a temp variable
temp = n;
// loop execute until the condition becomes false
while (temp > 0) {
temp = temp / 10;
digits++;
}
temp = n;
while (temp > 0) {
// determines the last digit from the number
last = temp % 10;
// calculates the power of a number up to digit times and
add the resultant to
// the sum variable
sum += (Math.pow(last, digits));
// removes the last digit
temp = temp / 10;
}
// compares the sum with n
if (n == sum)
// returns if sum and n are equal
return true;
// returns false if sum and n are not equal
else
return false;
}

// 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 ");
}
}
}

Enter the number: 153


Armstrong

QUESTION 11:
-------------
Description: Reverse the number

Example:
--------
Input = 123
Output = 321

package org.javaprograms;

import java.util.Scanner;

public class ReverseNumberExample {


private static Scanner rn;

public static void main(String[] args) {

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);
}
}

Enter the number :


9876
The reverse of the given number is: 6789

QUESTION 12:
-------------
Description: Count of the number

Example:
--------
Input = 123
Output = 3

package org.javaprograms;

import java.util.Scanner;

public class Count_of_number {

private static Scanner c;

public static void main(String[] args) {

c = new Scanner(System.in);

System.out.println("Enter the numbers : ");

int num=c.nextInt();

int count=0;

while (num != 0) {
num /= 10;
count++;

System.out.println("Total count of numbers : " + count);


}
}

Enter the numbers :


012345
Total count of numbers : 5

Enter the numbers :


123450
Total count of numbers : 6

QUESTION 13:
-------------
Description: Sum of the number

Example:
--------
Input = 123
Output = 6

package org.javaprograms;

import java.util.Scanner;

public class Sum_of_Number {

private static Scanner sn;

public static void main(String[] args) {

sn = new Scanner(System.in);

System.out.println("Enter the Input : ");


int n=sn.nextInt();

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);

Enter the Input :


123456
Sum of digits in a nu ber is : 21

QUESTION 14:
--------------
Description: Verify the number is palindrome number not

Example:
--------
Input = 141
Output = Palindrome

package org.javaprograms;

import java.util.Scanner;

public class Palindrome_number {

private static Scanner p;

public static void main(String[] args) {

p = new Scanner(System.in);

System.out.println("Enter the input : ");


int n=p.nextInt();

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");

}
}

Enter the input :


12321
Palindrome

Additional Program

Palindrome of a string

Solution:

package org.javaprograms;

import java.util.Scanner;

public class Palindrome_String {

private static Scanner ps;

public static void main(String[] args) {

ps = new Scanner(System.in);
System.out.println("Enter a word : ");

String str = ps.next();

String reverseStr = "";

int strLength = str.length();

for (int i = (strLength - 1); i >= 0; --i) {


reverseStr = reverseStr + str.charAt(i);
}

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.

QUESTIONS(Find the below Output)

----------------------------

QUESTION 1:

-------------

package org.test;

public class A {

public A() {

this("JAVA");

System.out.println("Default const...");

public A(int id) {

this(3456.5678f);

System.out.println(id);

}
public A(String name) {

this(12);

System.out.println(name);

public A(float sal) {

System.out.println(sal);

public static void main(String[] args) {

A a = new A();

Result:
3456.5679
12
JAVA
Default const...

QUESTION 2:

-----------

package org.test;

public class A extends B{

public A() {

System.out.println("Default const...");

public static void main(String[] args) {


A a = new A();

package org.test;

public class B {

public B() {

System.out.println("Super class");

Result:
Super class
Default const...

QUESTION 3:

------------

package org.test;

public class A extends B{

public A() {

System.out.println("Default const...");

public static void main(String[] args) {

A a = new A();

}
}

package org.test;

public class B {

public B() {

System.out.println("Super class");

public B(int id) {

System.out.println(id);

Result:
Super class
Default const...

QUESTION 4:

------------

package org.test;

public class A extends B {

public A() {

super(12);

System.out.println("Default const...");

public static void main(String[] args) {

A a = new A();

}
}

package org.test;

public class B {

public B() {

System.out.println("Super class");

public B(int id) {

System.out.println(id);

QUESTION 5:

-----------

package org.test;

public class B {

public B(int id) {

System.out.println(id);

package org.test;

public class A extends B {


public A() {

super(12);

System.out.println("Default const...");

public static void main(String[] args) {

A a = new A();

Result:
12
Default const...

QUESTION 6:

------------

package org.test;

public class A extends B {

public A() {

System.out.println("Default const...");

public static void main(String[] args) {

A a = new A();

package org.test;
public class B {

public B(int id) {

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)
------------------

1.What is Automation Testing and benefits?

2.Why should Selenium be selected as a test tool?

3.What is Selenium? What are the different Selenium components?

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?

6.Can Google Chrome be supported by Selenium IDE?


7.What are the different browsers supported by selenium?

8.What is the Classname,driver name for the below browsers,

1.Firefox browser

2.Chrome browser

3.IE

4.safari browser

5.Opera browser

9.What is the WebDriver and WebDriver is class or interface?

10.What is the method name to launch the url?

11.Method names to get the title and current URL?

12.What is the difference between close() and quit()?

ASSIGNMENT/INTERVIEW QUESTIONS SELENIUM – 1.1(Practical)


------------------

1.Launch the below URL's in firefox browser:

-------------------------------------------

1.Greens technologys - http://www.greenstechnologys.com/

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;

public class Chrome_Browser_Launch {

public static void main(String[] args) {

System.setProperty("Webdriver.gecko.driver",
"C:\\Users\\91636\\New eclipse - workspace\\
Selenium_Assignments\\DriverFiles\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

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

2.Launch the below URL's in chrome browser:

------------------------------------------

1.Greens technologys - http://www.greenstechnologys.com/

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;

public class Chrome_Browser_Launch {

public static void main(String[] args) {

System.setProperty("Webdriver.gecko.driver",
"C:\\Users\\91636\\New eclipse - workspace\\
Selenium_Assignments\\DriverFiles\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

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

3.Launch the below URL's in IE browser:

--------------------------------------

1.Greens technologys - http://www.greenstechnologys.com/

2.DemoQa Registration http://demo.automationtesting.in/Register.html

3.Greens technologys - http://www.greenstechnologys.com/

4.Greens technologys- http://greenstech.in/selenium-course-content.html

package org.selenium.assignments.day1;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class Ie_Edge_Browser_Launch {

public static void main(String[] args) {

System.setProperty("Webdriver.gecko.driver",
"C:\\Users\\91636\\New eclipse - workspace\\
Selenium_Assignments\\DriverFiles\\msedgedriver.exe");

WebDriver driver = new EdgeDriver();

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();
}

The above urls will get launched and closed

You might also like