多媒体测试系统
 
STUDENT
 
FACULTY
 
SCHOOL
 
SUPPORT
 
PUBLIC
 
SIGNUP
DAILY QUIZ
 
     
  M U L T I M E D I A    T E S T    S Y S T E M
 
Question of the Day for 6/3/2026
 
Subject: Java


Consider the following incomplete method hasTwoChild which should return true when at least one node in the tree has two children.

private boolean hasTwoChild(TreeNode node)
{
if (node == null)
return false;

TreeNode leftNode = node.getLeft();
TreeNode rightNode = node.getRight();

if (leftNode != null) && (rightNode != null)
return true;
else
return /* missing code */;
}

Which of the following can be used to replace /* missing code */ so that the method hasTwoChild will work as intended?
  1. (hasTwoChild(leftNode) || hasTwoChild(rightNode))
  2. (hasTwoChild(leftNode) || hasTwoChild(leftNode))
  3. false
  4. true
  5. (hasTwoChild(leftNode) && hasTwoChild(rightNode))

Email Subscriptions: To receive Question of the Day via email, sign up for a student account and subscribe to the mailing lists of your choice on AP, SAT, and MCAT exams and college subjects.
     
 
Blog Posts    News Digest    Contact Us    About Developer    Privacy Policy

©1997-2026 ecourse.org. All rights reserved.