Class, Variable, Constructor, Object, Method Questions

Similar documents
CMSC 132: Object-Oriented Programming II

1 Shyam sir JAVA Notes

Practice for Chapter 11

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

Compaq Interview Questions And Answers

Java Fundamentals (II)

CS-202 Introduction to Object Oriented Programming

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)

15CS45 : OBJECT ORIENTED CONCEPTS

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

CMSC 132: Object-Oriented Programming II

Java: introduction to object-oriented features

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

CS260 Intro to Java & Android 03.Java Language Basics

Declarations and Access Control SCJP tips

Programming overview

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Array. Prepared By - Rifat Shahriyar

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

Chapter 5. Inheritance

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

More On inheritance. What you can do in subclass regarding methods:

What is Inheritance?

Chapter 5 Object-Oriented Programming

Inheritance. Transitivity

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Points To Remember for SCJP

Java Magistère BFA

CONSTRUCTOR & Description. String() This initializes a newly created String object so that it represents an empty character sequence.

Chapter 4 Java Language Fundamentals

Core Java Interview Questions and Answers.

Inheritance (Part 5) Odds and ends

Inheritance and Polymorphism

Character Stream : It provides a convenient means for handling input and output of characters.

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

COP 3330 Final Exam Review

Object Oriented Programming. Java-Lecture 11 Polymorphism

public class Test { static int age; public static void main (String args []) { age = age + 1; System.out.println("The age is " + age); }

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

1- Differentiate between extends and implements keywords in java? 2- What is wrong with this code:

CS Programming I: Inheritance

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Questions Answer Key Questions Answer Key Questions Answer Key

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

CS Internet programming Unit- I Part - A 1 Define Java. 2. What is a Class? 3. What is an Object? 4. What is an Instance?

Chapter 11 Inheritance and Polymorphism. Motivations. Suppose you will define classes to model circles,

Chapter 10 Inheritance and Polymorphism. Dr. Hikmat Jaber

Lecture Notes Chapter #9_b Inheritance & Polymorphism

CH. 2 OBJECT-ORIENTED PROGRAMMING

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Exception-Handling Overview

Fundamentals of Object Oriented Programming

Rules and syntax for inheritance. The boring stuff

Introduction to Programming Using Java (98-388)

Inheritance (continued) Inheritance

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Full file at Chapter 2 - Inheritance and Exception Handling

PROGRAMMING LANGUAGE 2

CLASS DESIGN. Objectives MODULE 4


OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

F I N A L E X A M I N A T I O N

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. January 11, 2018

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

Implements vs. Extends When Defining a Class

Example: Count of Points

COMP200 - Object Oriented Programming: Test One Duration - 60 minutes

Objective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5

Example: Count of Points

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

STRUCTURING OF PROGRAM

Java and C# in Depth

ASSIGNMENT NO 13. Objectives: To learn and understand concept of Inheritance in Java

AP CS Unit 6: Inheritance Notes

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

EKT472: Object Oriented Programming. Overloading and Overriding Method

Exceptions. CSE 142, Summer 2002 Computer Programming 1.

Exceptions. Readings and References. Exceptions. Exceptional Conditions. Reading. CSE 142, Summer 2002 Computer Programming 1.

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

CLASSES AND OBJECTS IN JAVA

OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70

QUESTIONS FOR AVERAGE BLOOMERS

Instance Members and Static Members

Selected Questions from by Nageshwara Rao

Inheritance Motivation

Polymorphism. return a.doublevalue() + b.doublevalue();

CISC-124. Passing Parameters. A Java method cannot change the value of any of the arguments passed to its parameters.

Selected Java Topics

A Quick Tour p. 1 Getting Started p. 1 Variables p. 3 Comments in Code p. 6 Named Constants p. 6 Unicode Characters p. 8 Flow of Control p.

Exercise: Singleton 1

20 Most Important Java Programming Interview Questions. Powered by

Transcription:

Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx https://javaconceptoftheday.com/java-practice-questions-on-classes-andobjects/ https://www.geeksforgeeks.org/java-interview-questions-constructors/ https://www.javabykiran.com/interview/corejava/constructor-interviewquestions.php https://javaconceptoftheday.com/java-interview-questions-onconstructors/ https://www.javapedia.net/methods https://javaconceptoftheday.com/important-java-interview-questions-onmethod-overloading/ http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions What restrictions are placed on method overloading? What is the difference between String and StringBuffer? Can a private method of a superclass be declared within a subclass? What is the default value of an object reference declared as an instance variable? What is the difference between a constructor and a method? Or How can a subclass call a method or a constructor defined in a superclass? Can a top-level class be private or protected? Why Java does not support multiple inheritance? How are this() and super() used with constructors? What is Method Overriding? What restrictions are placed on method overriding? What is a singleton class? Or What is singleton pattern? What are the Object and Class classes used for? Which class should you use to obtain design information about an object? Differentiate between a Class and an Object?

What is a singleton class? Or What is singleton pattern? What is method overloading and method overriding? Or What is difference between overloading and overriding? If a class is declared without any access modifiers, where may the class be accessed? Does a class inherit the constructors of its superclass? Which java.util classes and interfaces support event handling? Can an object s finalize() method be invoked while it is reachable? What is the purpose of the Runtime class? What is the purpose of the System class? Can an unreachable object become reachable again? What is a bean? Where can it be used? What is the functionality of instanceof()?

What would happen if you say this = null? I want to create two instances of a class,but when trying for creating third instance it should not allow me to create. What i have to do for making this? What is the difference between an object and an instance? What is heap in Java? Why default constructor of base class will be called first in java? What are the other ways to create an object other than creating as new object?

What is the difference between instance, object, reference and a class? https://www.careerride.com/java-objects-classes-methods.aspx Define class and object. Explain them with an example using java What is a method? Provide several signatures of the methods Difference between instance variable and a class variable Explain how to create instance of a class by giving an example Define an abstract class. Explain its purpose What is the difference between an Abstract class and Interface? What is singleton class? Where is it used? What is a native method? Difference between a public and a non-public class What is the purpose of the Runtime class? What is the difference between a and a non- inner class? Difference between the String and StringBuffer classes What is the Dictionary class? What is the ResourceBundle class? What is the Vector class? What is the SimpleTimeZone class? What is the purpose of the System class? How are this() and super() used with constructors? https://javaconceptoftheday.com/java-practice-questions-on-classes-andobjects/ Which of the following is true about Static Initialization Block? A. We can use only members of a class inside the Static Initialization Block. B. Static Initialization Blocks are mainly used to initialize fields of a class. C. Static Initialization Block is the first block to be executed after class is loaded in the memory. D. All of the above. Where the initialization blocks are stored in the memory? What will be the output of this program? int i; System.out.println(1); i = 100; public class StaticInitializationBlock

System.out.println(2); public void main(string[] args) System.out.println(3); System.out.println(A.i); What happens when you compile the below class? int i; System.out.println(i); Is the below code written correctly? System.out.println(1); How many initialization blocks are there in the below Class A? int a = 50; a = 50; a = 50; What will be the outcome of the following program? public System.out.println(1);

System.out.println(2); System.out.println(3); public void main(string[] args) A a; What will be the output of this program? int first; String second; System.out.println(1); first = 100; System.out.println(2); second = "SECOND"; public class StaticInitializationBlock System.out.println(3); public void main(string[] args) System.out.println(4); System.out.println(A.first); System.out.println(A.second); What will be the output of the below program?

int i; i = 100; System.out.println(1); void Method() System.out.println(i); System.out.println(2); public class B System.out.println(3); public void main(string[] args) System.out.println(4); System.out.println(A.i); A.Method(); What is the difference between SIB and IIB? SIB - Static Initialization Block IIB Instance Initialization Block https://www.geeksforgeeks.org/java-interview-questions-constructors/ What is a Constructor? Do we have Copy Constructor in Java? What is Constructor Chaining? Can we call sub class constructor from super class constructor? What happens if you keep a return type for a constructor? What is No-arg constructor? How a no argument constructor is different from default Constructor? What are private constructors and where are they used? When do we need Constructor Overloading? Do we have destructors in Java?

https://www.javabykiran.com/interview/corejava/constructor-interviewquestions.php Is it mandatory to define a constructor in a class? Define a constructor Can we define a method with the same name as that of a class? How can a compiler and a JVM differentiate between constructor and method definitions if both have same name as the class has? What are the rules for defining a constructor? If we place a return type in a constructor prototype will it throw error? Why a return type is not allowed for Constructor? How does a compiler and JVM differentiate constructor and method invocations if both have same name as class name? Can we declare constructor as private? Why a compiler given constructor is called as default constructor? Why a constructor name is same as class name? What is default accessibility modifier of a default constructor? In which situation it is mandatory for the developer to provide constructor explicitly? When does a compiler provide default constructor? If class has explicit constructor then will it have a default constructor? What is Constructor Chaining? What will happen if one keeps a return type for a constructor? Can we call sub class constructor from super class constructor? What is no-arg constructor? What is the use of private constructor? What is constructor chaining and how can it be achieved in Java? Can we use this() and super() in a method? What is default constructor? Can we overload constructors? Does a constructor create the object? What are the common uses of this keyword in java? https://javaconceptoftheday.com/java-interview-questions-onconstructors/ Can you create an object without using new operator in Java? Using newinstance() method Using clone() method Using object deserialization What is constructor chaining? Can we call sub class constructor from super class constructor?

What happens if you keep return type for a constructor? What is No-arg constructor? What is the use of private constructor? Can we use this() and super() in a method? https://www.javapedia.net/methods Can a main method be declared final? Is the main() method required for all java classes? Difference between arguments and parameters in Java. What is the return type of main() method?

Why does the main() method declared? What is the the argument for main() method? Can a main() method be overloaded? When no command line arguments are passed, does the String array parameter of main() method be null? Can we invoke a method on a null object reference in Java? Explain the Default method for interfaces in Java 8. Advantages of default method in Interface feature in Java 8. Explain the interface methods feature in Java 8. Advantages of using interface method in Java 8. Difference between default and methods in Java interface. Explain pass by reference and pass by value in Java? Difference between System.exit(0), exit (1) and exit(-1) in Java. What is virtual function/method in Java? Can we define a method in a Java interface? What is fluent interface in Java? Explain method chaining in Java. What is synthetic method in Java? What is bridge method in Java? What is a method reference in Java 8? Types of method references in Java 8. Are Java calls less expensive than non- calls? What is lambda expression in Java 8? What is the target type of lambda expression? Can you Serialize lamda expression in Java8? What is System.out.println expression? Other names for default methods in Java 8. Is abstract modifier allowed in default method? What is the scope of default methods in Java8? How do I extend Interfaces that contain Default Methods? Explain the scenario how Default Method can cause Multiple Inheritance Ambiguity Problem. Why Java doesn't allow overriding of methods? https://javaconceptoftheday.com/important-java-interview-questions-onmethod-overloading/ What is method overloading? What is method signature? What are the things it consist of?

Can we declare one overloaded method as and another one as non-? How do compiler differentiate overloaded methods from duplicate methods? Is it possible to have two methods in a class with same method signature but different return types? In MyClass, there is a method called mymethod with four different overloaded forms. All four different forms have different visibility ( private, protected, public and default). Is mymethod properly overloaded? Can overloaded methods be synchronized? Can we overload main() method? Can we declare overloaded methods as final? In the below class, is constructor overloaded or is method overloaded? public public A() //-----> (1) void A() //-----> (2) Overloading is the best example of dynamic binding. True or false? Can overloaded method be overrided?