Questions & Answers

Objective Questions Java & Selenium

This part of the blog will help you to get an idea of the basic objective questions which would arise during the course. Also, these objective questions will clear all the doubts so that individual can understand the concepts behind the same.


Que: Is it possible to run a java program with error?

Ans: According to me we can run a java program with exceptional error or if I would be more specific than we can say run time errors. But there shouldn’t be any syntax or compile error present in the code.
java program error

Ques: How to create a folder with name “CON” in the windows?

Ans: CON is the Device driver name reserved by the MS-DOS. Likewise, there are few more names are reserved:
CON: Keyboard and display
PRN: System list device, usually a parallel port
AUX: Auxiliary device, usually a serial port
We can’t create any file or folder using these reserved keywords.

Que: Can we create two or more classes in a single java file?

Ans: Yes. We can create two or more classes(with default access) in a single java file. But make sure that main() method should be defined under the main class. Here, the main class refers to the class having the same name of java file.

Que: Can we access ‘private’ variables of a class from any other class without using that private variable names?

Ans: Yes. We can access a ‘private’ variable via getter and setter methods. While using these methods we don’t need to have the real name of the variables.
Reference: Parameterized Constructors v/s Setter and Getter function in JAVA.


Que: Can Constructors be invoked without creating any object of that class?

Ans: We all know that constructors have been invoked whenever we create an object of the associated class. However, it is possible to invoke Constructors without creating any object of that class. We just need to call the Class using the below statement:
new ClassName();
Calling Constructor without Object


Related Links:

TestNG:

Java Basics:

Java File Handling:

OOPs Concept:

Java Question And Answer:

Java Programs:

Selenium Tutorials:

JIRA:

Agile:


170total visits,3visits today