ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Part 2 | Cognizant Walk-In Drive 2025 🌸 | Must-Know Java Questions | Crack your First Job !

Автор: XAdmin

Загружено: 2025-07-11

Просмотров: 146

Описание: In this video we are going to discuss about the java interview question for the cognizant walk-in Drive
Q14. What is a Class in Java?
Ans:
A class in Java is a blueprint, template, or prototype used to create objects.
It defines the properties (fields/variables) and behaviors (methods/functions) that the objects created from the class will have.
Think of a Class Like:
A blueprint for a house.
The blueprint defines:
How many rooms it will have
What the dimensions are
Where doors/windows will be
But it's not the house itself—you use the blueprint to build multiple houses.
In the same way:
A class defines the structure
An object is a real-world instance of that structure

Q15. What is an Object in Java?
Ans:
An object is a instance of a class.
It is a runtime entity that has:
State → represented by fields/variables
Behavior → represented by methods/functions

So, An object is an instance of a class. It occupies memory space and has a unique identity. You can create, modify, and use objects to perform tasks defined in the class.
Memory View:
When you create an object:
Student s1 = new Student("Ashish", 22);
new → allocates memory in the heap
s1 → reference to that memory (object)

Q16. What is encapsulation ?
Ans:
Encapsulation is one of the four main pillars of Object-Oriented Programming (OOP) and it means:
Hiding internal data and allowing access only through methods.
In other words:
It binds data (fields) and code (methods) together into a single unit (the class).
It protects the data from outside access or unauthorized modification.

Encapsulation is the process of wrapping data and methods into a single unit (class) and restricting direct access to some of the object's components.
It is implemented in Java using:
private → for data hiding
public → getter and setter methods for controlled access


Q17. Why main() method is public, static and void in java ?
Ans:
public static void main(String[] args)
public — Accessible by JVM
The main() method must be accessible to the Java Virtual Machine (JVM) from outside the class to start execution.
public means it is visible to all.
If it were private or protected, JVM wouldn’t be able to access it, and it would throw a runtime error.
Think of it like: A public gate to enter your program.
static — No Object Needed
main() is called by the JVM without creating an object of the class.
static allows the JVM to call it directly using the class name.
If main() were not static, the JVM would need to create an object first, which creates a chicken-and-egg problem — JVM needs to run main() to create objects, but main() needs an object to run.
Think of it like: A switch on the wall — you don’t need to build anything else to turn it on.
void — No Return Value
main() doesn’t return anything to the JVM.
It is the starting point of the program, not something that computes a result.
That's why its return type is void (i.e., it returns nothing).
Think of it like: A driver that starts your engine — it doesn’t give you a result; it just begins execution.



Q18. What is a Constructor in Java?
Ans:
A constructor in Java is a special method that is used to create and initialize an object of a class.
A constructor is a block of code similar to a method that is automatically called when an object is created.

Q19. What is difference between length and length() method in java?
Ans:
Key Difference
Feature
length
length()
Used With
Arrays
Strings (String class)
Type
Field / Property
Method
Syntax
array.length
string.length()
Returns
The number of elements in the array
The number of characters in the string
Parentheses
❌ No parentheses
✅ Must have parentheses ()

Q20. Difference between Character Constant and String Constant in Java?
Ans:
In Java, both character constants and string constants represent text, but they are fundamentally different in syntax, size, and type.



Q21. Explain about abstract classes in java?
Ans:
An abstract class in Java is a class that cannot be instantiated directly and is used to provide a base for other classes. It may contain:
Abstract methods (without body)
Concrete methods (with implementation)
Fields (variables) and constructors
An abstract class is a class declared using the abstract keyword. It may contain incomplete methods that subclasses must override.



Q22. Can we create constructor in abstract class?
Ans:
Yes, you can create a constructor inside an abstract class in Java.
Even though you cannot instantiate an abstract class directly, its constructor is still called when a subclass object is created.


Q24. Why Allow Constructors in Abstract Classes?
Ans:
To initialize common fields shared by all subclasses
To perform setup tasks for subclasses
To allow constructor chaining through super()

#java #javainterview #javainterviewquestions

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Part 2 | Cognizant Walk-In Drive  2025 🌸  | Must-Know Java Questions  |  Crack your First Job !

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Cognizant Walk-In Drive  2025 🌸  | Must-Know Java Questions  |  Crack your First Job ! Part 1

Cognizant Walk-In Drive 2025 🌸 | Must-Know Java Questions | Crack your First Job ! Part 1

Learn Angular 19 : 🔥 Master ngDoCheck()  Life cycle hook method 🔥  | Real World Example | Episode 10

Learn Angular 19 : 🔥 Master ngDoCheck() Life cycle hook method 🔥 | Real World Example | Episode 10

Coding with John Tutorials

Coding with John Tutorials

Как устроена База Данных? Кластеры, индексы, схемы, ограничения

Как устроена База Данных? Кластеры, индексы, схемы, ограничения

10. DYNAMIC MEMORY ALLOCATION IN C Programming | C Programming Beginner tutorial | Intelle Learn |

10. DYNAMIC MEMORY ALLOCATION IN C Programming | C Programming Beginner tutorial | Intelle Learn |

Crack HCL 2nd Round Technical Java Interview in 2025 !🔥 Real Interview  Questions for 3+ year

Crack HCL 2nd Round Technical Java Interview in 2025 !🔥 Real Interview Questions for 3+ year

💡 Patterns: Transaction Script и Template Method для JavaScript и TypeScript, паттерны GoF

💡 Patterns: Transaction Script и Template Method для JavaScript и TypeScript, паттерны GoF

Learn Angular 19 : What is  Angular Components in details with example #Episode 2

Learn Angular 19 : What is Angular Components in details with example #Episode 2

КАК НЕЛЬЗЯ ХРАНИТЬ ПАРОЛИ (и как нужно) за 11 минут

КАК НЕЛЬЗЯ ХРАНИТЬ ПАРОЛИ (и как нужно) за 11 минут

Европейские подсвинки Путина | Кто они и почему хотят развалить Россию (English subtitles) @Max_Katz

Европейские подсвинки Путина | Кто они и почему хотят развалить Россию (English subtitles) @Max_Katz

Многопоточность в Java: объяснение за 10 минут

Многопоточность в Java: объяснение за 10 минут

Это ЛУЧШИЙ способ запоминания лексики

Это ЛУЧШИЙ способ запоминания лексики

Создавать REST-клиенты в Spring Boot 4 стало еще проще!

Создавать REST-клиенты в Spring Boot 4 стало еще проще!

Лямбда-выражения в Java — простое полное руководство

Лямбда-выражения в Java — простое полное руководство

С этого устройства взяты почти все звуки Смешариков. И я его купил!

С этого устройства взяты почти все звуки Смешариков. И я его купил!

Интернет в небе: Сергей

Интернет в небе: Сергей "Флеш" о том, как «Шахеды» и «Герберы» научились работать в одной связке

Crack HCL Java Interview in 2025 !🔥 Real Interview  Questions for 3+ year  | 1st Technical Round 💻

Crack HCL Java Interview in 2025 !🔥 Real Interview Questions for 3+ year | 1st Technical Round 💻

Kubernetes — Простым Языком на Понятном Примере

Kubernetes — Простым Языком на Понятном Примере

🔥 Crack  J.P Morgan Chase & Co  2nd Java Technical Round  4+ year Exp | Selected ✅

🔥 Crack J.P Morgan Chase & Co 2nd Java Technical Round 4+ year Exp | Selected ✅

The Most Expensive Tech Bet in History

The Most Expensive Tech Bet in History

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]