Question 1
Answer
Question 1
Is null a keyword?
Answer
Answer: No, the null is not a keyword.
Question 2
Answer
Question 2
What is an applet?
Answer
Answer: Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser
Question 3
Answer
Question 3
What is the lifecycle of an applet?
Answer
Answer: init() method – Can be called when an applet is first loaded start() method – Can be called each time an applet is started.
paint() method – Can be called when the applet is minimized or maximized. stop() method – Can be used when the browser moves off the applet’s page. destroy() method – Can be called when the browser is finished with the applet.
Question 4
Answer
Question 4
Does Java support multiple inheritances?
Answer
Answer: Java doesn’t support multiple inheritances.
Question 5
Answer
Question 5
What’s new with the stop(), suspend() and resume() methods in JDK 1.2 ?
Answer
Answer: These methods have been deprecated in JDK 1.2.
Also Checkout: TCS NQT Sample Question Paper
Question 6
Answer
Question 6
What is the Vector class?
Answer
Answer: The term Vector class provides the ability to implement a growable array of objects.
Question 7
Answer
Question 7
Define How many objects are created in the following piece of code?
MyClass c1, c2, c3;
c1 = new MyClass ();
c3 = new MyClass ();
Answer
Answer: Only 2 objects are created, c1 and c3. The reference c2 is only declared and not initialized.
Question 8
Answer
Question 8
What is the difference between the >> and >>> operators?
Answer
Answer: The >> operator carries the sign bit when shifting right while the >>> zero-fills bits that have been shifted out.
Question 9
Answer
Question 9
What is the difference between this() and super()?
Answer
Answer: this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor.
Question 10
Answer
Question 10
What is a native method?
Answer
Answer: A native method is a method that is applied in a language other than Java.
Question 11
Answer
Question 11
What value does read Line() return when it has reached the end of a file?
Answer
Answer: The readLine() method returns null when it has reached the end of a file.
Question 12
Answer
Question 12
What is the Java API?
Answer
Answer: The Java API is a large collection of ready-made software components that provide many usefulcapabilities, such as graphical user interface (GUI) widgets.
Question 13
Answer
Question 13
Why there are no global variables in Java?
Answer
Answer: Global variables are globally accessible. Java does not support globally accessible variables due to following reasons:
The global variables breaks the referential transparency Global variables creates collisions in namespace.
Question 14
Answer
Question 14
What are different types of access modifiers?
Answer
Answer:
public: Any thing declared as public can be accessed from anywhere.
private: Any thing declared asprivate can’t be seen outside of its class.
protected: Any thing declared as protected can be accessedby classes in the same package and subclasses in the other packages.
default modifier : Can beaccessed only to classes in the same package.
Question 15
Answer
Question 15
What is Constructor?
Answer
Answer: A constructor is a special method whose task is to initialize the object of its class. It is special because its name is the same as the class name.
They do not have return types, not even void and therefore they cannot return values. They cannot be inherited, though a derived class can call the base class constructor. Constructor is invoked whenever an object of its associated class is created.
Question 16
Answer
Question 16
What is an Iterator ?
Answer
Answer: The Iterator interface is used to step through the elements of a Collection. Iterators let you process each element of a Collection. Iterators are a generic way to go through all the elements of a Collection no matter Define How it is organized. Iterator is an Interface implemented a different way for every Collection.
Question 17
Answer
Question 17
What is the difference between Reader/Writer and InputStream/Output Stream?
Answer
Answer: The Reader/Writer class is character-oriented and the InputStream/OutputStream class is byte- oriented.
Question 18
Answer
Question 18
What is servlet?
Answer
Answer: Servlets are modules that extend request/response-oriented servers, such as java-enabled webservers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company’s order database.
Question 19
Answer
Question 19
What is clipping?
Answer
Answer: Clipping is the process of confining paint operations to a limited area or shape.
Question 20
Answer
Question 20
What is memory leak?
Answer
Answer: A memory leak is where an unreferenced object that will never be used again still hangs around in memory and doesnt get garbage collected.
Question 21
Answer
Question 21
Can a for statement loop indefinitely?
Answer
Answer: Yes, a for statement can loop indefinitely. For example, consider the following: for(;;)
Question 22
Answer
Question 22
Explain Java Coding standards for Methods?
Answer
Answer: Method names should start with small letters.
Method names are usually verbs
If a method contains multiple words, every inner word should start with an uppercase letter. Ex : toString()
Method name must be combination of verb and noun Ex : getCarName(),getCarNumber()
Question 23
Answer
Question 23
Why Java is not a pure Object Oriented language?
Answer
Answer: Java supports primitive types such as int, byte, short, long, etc that why it is not said to be a pure object-oriented language.
Question 24
Answer
Question 24
What are the access modifiers?
Answer
Answer: Java provides three access controls such as public, private and protected access modifier. When none of these are used, it’s called default access modifier.
Question 25
Answer
Question 25
Can we overload the main method?
Answer
Answer: Yes, we can overload the main method with syntax as public static void main(String args[]).
Also Checkout